Is there anyway to send multiple imageURI’s using file transfer plugin.
fileTransfer.upload(data.img1, url, options);
This line uploads only one image to the URL, data is appended in options but I’ve multiple images and want to upload in one hit.
I want to upload several pictures to server at the same time,the native plugin provide transfer,but this plugin can only upload a file at the same time.I don’t want to call transfer.upload in while or for.
What method can upload multiple files at the same time? Thank you very much for your reply!!!
I don’t think there is an extra method for that, I would suggest using for with promises or bundeling the files in one (as example in zip file that gets extracted at the server)
you could try that plugin to zip them: https://github.com/FortuneN/cordova-plugin-zeep
or you can combind the images some how in to on single file - like storing their base 64 values along with their mime type in a json.(But I think the loop is the better solution)
Unless there is a specific reason to use the native file-transfer plugin I wouldn’t use it - use the js methods instead, because they support multiple files at once uploading.
So now the methods that I can think of to combining the files:
Idea:
we have to vars transferred: one is a Json on which file type is transferred and at what location it is in the second var that is the binary data of all files chained into one long string.
When retrieving the files, you split the binary data accordingly to the positions in the json.
You could also use base64 strings instead of binary data and include that directly in your json, but this would increase the file size notably.
Disclaimer: I haven’t tested it yet, but it should work.
Hi, If anyone are still facing the issue, I have written a detailed answer to it on Stack-overflow, below is the link for the same. Where I have explained how to convert an image to base64 and upload it to server via API.