@ank5 wrote:
I am using a $cordovaFileTransfer in Ionic to upload a set of documents to the server. Below is the code
//docList is an array of all the documents that need to be uploaded docList.map(function(doc) { console.log('Document to upload '+doc); var targetPath = cordova.file.dataDirectory + doc; var trustHosts = true; var options = { mimeType: "application/octet-stream", headers: { "Content-Type": null, } }; var server = nodeserver + '/upload'; return $cordovaFileTransfer.upload(server, targetPath, options, trustHosts); .then(function (result) { console.log("File uploaded", result); }) .catch(function(error) { console.log('Upload failed '+JSON.stringify(error)); }) })
My requirement is such that I have to do this synchronously. I don't want to upload the second document in docList array until the first document is correctly uploaded, and so on.
Is there a way to make the upload operation synchronous?
Posts: 1
Participants: 1