Retrofit multiple file upload with progress in android

Sheetal Kumar Maurya
Impulsive Web
Published in
2 min readFeb 20, 2019

Upload file in a Mobile Application is a general task for a developer. But when you need progress with file upload, it goes complex to manage due to data will transfer in multiple parts. Some other issue is there to get the sequence of file upload, Total progress, Which file is uploading, etc is a critical task to do. Here I have created a class to make multiple file upload easy for all developers with the retrofit library.

I have created a class FileUploader that usage Retrofit Library for connecting to API. To upload the file the code skeleton is as follow:

fileUploader.uploadFiles() function takes 5 arguments.

1. API endpoint

2. API file key

3. An array of the File object (Files to be upload)

4. Callbacks

5. Authorization Token (Optional, pass it API require auth token)

A full example of MainActitity.java is as below:

ApiClient.java

FileUploader.java

You can download the full working code sample from GitHub.

For any other assistance, you can visit DevStudioOnline.

--

--