Start a new topic

Issue while uploading File using Kinvey Backbone SDK

I am trying to upload a file File to Kinvey using Javascript Backbone SDK, and I am using the demo code present there in the SDK guide -

<form enctype="multipart/form-data" method="post" name="fileUpload"> <input multiple type="file" /> <input type="submit" value="Upload" /></form><script> var form = $('[name="fileUpload"]'); form.on('submit', function(e) { e.preventDefault(); // Upload all the submitted files in parallel. var uploads = []; var fileList = form.find('[type="file"]')[0].files; for(var i = 0, length = fileList.length; i < length; i += 1) { var file = fileList.item(i); uploads.push(Kinvey.File.upload(file)); } // Wait until all files are uploaded. var promise = Kinvey.Defer.all(uploads); promise.then(function(response) { // response is an Array of file metadata as returned by Kinvey. }, function(error) { // One or more uploads failed. }); });</script>

When hit on Upload button, although the file is getting uploaded, but the controls are always coming to the error callback and never in the success part.

Please see the attached response, for more clarification.

Login or Signup to post a comment