I want to upload files one by one.
For eg: if i have 3 images, 1 PDF and 1 video file.. i want to upload all multipart upload the to same key. which mean - > .addMultipartFile("myfile",file)
And also i need to show progress dialog with no. of file uploaded.
if one of the file is failed to upload, i want to cancel all the queued files.
As much as I have seen (tried it like one week) that's not possible
This is not present in upload currently. I will add this in new version.
Hi @MyNameIsAnti and @haneef5k, I have added this support, please check the latest version 1.0.2
Wow., Thanks @amitshekhariitbhu
@amitshekhariitbhu Looking for an example, how to implement this feature.
I have many images to upload to the server.
Is it bad to run this in a loop?
Here's my code
for (int i = 0; i < listFiles.length; i++) {
AndroidNetworking.upload(url)
.addMultipartFile("file", file)
.addMultipartParameter("name", name)
.setTag("uploadTest")
.setPriority(Priority.HIGH)
.build()
.setUploadProgressListener(new UploadProgressListener() {
@Override
public void onProgress(long bytesUploaded, long totalBytes) {
// do anything with progress
Log.d(TAG,"bytesUploaded: "+(int)bytesUploaded + ", totalBytes:"+(int)totalBytes);
}
})
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
// do anything with response
}
@Override
public void onError(ANError error) {
// handle error
}
});
}
Hi, I found simple and well solution my api call is basically rx based, @ahaneef29 , @joemackay
return Rx2AndroidNetworking.upload(API_BASE_URL + CREATE_POST)
.addHeaders("Accept", "application/json")
.addHeaders("Authorization", token)
.addMultipartParameter("title", title)
.addMultipartParameter("description", description)
.addMultipartFileList("images[]", files)
.build()
.getObjectSingle(Data::class.java)
Most helpful comment
Hi @MyNameIsAnti and @haneef5k, I have added this support, please check the latest version
1.0.2