# $cordovaFileTransfer starts uploading to s3 and then fails

**URL:** <https://forum.ionicframework.com/t/cordovafiletransfer-starts-uploading-to-s3-and-then-fails/27253>\
**Category:** ionic-v1\
**Created:** [June 27, 2015, 2:16am UTC](https://forum.ionicframework.com/t/cordovafiletransfer-starts-uploading-to-s3-and-then-fails/27253 "2015-06-27T02:16:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffchuber](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jeffchuber/32/90557_2.png) [@jeffchuber](https://forum.ionicframework.com/u/jeffchuber)\
**Post date:** [June 27, 2015, 2:16am UTC](https://forum.ionicframework.com/t/cordovafiletransfer-starts-uploading-to-s3-and-then-fails/27253/1 "2015-06-27T02:16:59Z")

</div>

Hi Everyone,

I’m trying to have the user select some images from their gallery and then upload them to s3 using a presigned url that is returned from my server. I got all this working very well. The weird thing now is that the images randomly die during the upload process. Here is the log:

> results[i], file:///…/tmp/cdv\_photo\_145.jpg  
> progress: 1.792584690709665  
> progress: 3.58516938141933  
> progress: 5.377754072128995  
> progress: 7.17033876283866  
> progress: 8.962923453548326  
> progress: 10.75550814425799  
> progress: 12.548092834967656  
> progress: 14.34067752567732  
> progress: 16.133262216386985  
> ERROR: {“code”:3,“source”:“file:///…/tmp/cdv\_photo\_145.jpg”,“target”:“[https://bucket.s3-us-west-2.amazonaws.com/uploads/YaWaEYK5Djwxa4ZZZFq9mFmCFQecsvDj/cdv\_photo\_145.jpg?X-Amz-Algorithm=ASS4-HMAC-SHA256&X-Amz-Credential=AWSID/20150627/us-west-2/s3/aws4\_request&X-Amz-Date=20150627T011212Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=d28e94698f1d59b1d4fa8344d38886c757199af92ed93839077c2a2b0f158daf",“http\_status”:null,“body”:null,"exception](https://bucket.s3-us-west-2.amazonaws.com/uploads/YaWaEYK5Djwxa4ZZZFq9mFmCFQecsvDj/cdv_photo_145.jpg?X-Amz-Algorithm=ASS4-HMAC-SHA256&X-Amz-Credential=AWSID/20150627/us-west-2/s3/aws4_request&X-Amz-Date=20150627T011212Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=d28e94698f1d59b1d4fa8344d38886c757199af92ed93839077c2a2b0f158daf%22,%22http_status%22:null,%22body%22:null,%22exception)”:null}

and here is the relevant code:

> var ftOptions = new FileUploadOptions();  
> ftOptions.fileKey = ‘file’;  
> ftOptions.fileName = data\_url.substr(data\_url.lastIndexOf(‘/’)+1);  
> ftOptions.mimeType = ‘image/jpeg’;  
> ftOptions.httpMethod = ‘POST’;  
> ftOptions.headers = {Connection : “close”};

> $cordovaFileTransfer.upload(decodeURIComponent(data.url), data\_url, ftOptions).then(function(result) {  
> console.log("SUCCESS: " + JSON.stringify(result.response));  
> }, function(err) {  
> console.log("ERROR: " + JSON.stringify(err));  
> }, function (progress) {  
> console.log("progress: " + (progress.loaded / progress.total) \* 100);  
> }, false);

I’m currently using the ios-sim emulator. I would really appreciate any help! I’ve also tried using FileTransfer, but I couldn’t get it to actually upload the file (just the file name) – which is also how I know that my presigned S3 url is working properly.

Thanks!

---

<div class="post-metadata">

**Author:** ![udayakanth](https://avatars.discourse-cdn.com/v4/letter/u/aca169/32.png) [@udayakanth](https://forum.ionicframework.com/u/udayakanth)\
**Post date:** [July 17, 2015, 4:06am UTC](https://forum.ionicframework.com/t/cordovafiletransfer-starts-uploading-to-s3-and-then-fails/27253/2 "2015-07-17T04:06:47Z")

</div>

Hi can you please share the complete code with us?
