0

I am using Cordova FileTransfer plugin to upload image file in Amazon S3 server. Here is my procedure of performing fileTransfer

  1. I called my server with the photoURL and get the keys for submitting amazon s3 server which I included as key value pair in params
  2. Then I am using the fileTransfer plugin for uploading the file with following codes.

        var options = new FileUploadOptions();
        options.fileKey = "file";
        options.fileName = fileName;
        options.mimeType = "image/jpeg";
        options.chunkedMode = false;
        options.encodeURI= false;
    
        var headers={
            'X-Amz-Acl': 'public-read'
        };
    
        options.headers = headers;
        options.params = params;
    
        var ft = new FileTransfer();
        ft.upload(fileURL,form.action, win, fail, options) 
    
  3. The response returns to the win function returning json response

        bytesSent: 31968
        objectId: ""
        response: ""
        responseCode: 204
    

    The file is not uploaded and I am not getting any response URL of my image

  4. I have used 'Content-Type': 'image/jpeg' But its responding 412 error code and in Message Bucket POST must be of the enclosure-type multipart/form-data. Why this is the response as I am sending speically to use image/jpeg content type?

  5. Here I followed this answer By pull method. But It return in fails fuction. I get error code 3 which say MalformedXML in body and error saying "Write error: ssl=0x6d3c2c20: I/O error during system call, Connection reset by peer"


Please someone help me to get what I am missing here. Thanks in advance.

Community
  • 1
  • 1
  • Was this resolved? – Cozzbie Aug 04 '16 at 10:13
  • Yes. For android the response is null returned but for iOS response is okay. So for android the work around will be the form.action + params.key; And following code are enough for sending the file( 4, 5 points are ignored ) var options = new FileUploadOptions(); options.fileKey = "file"; options.fileName = fileName; options.chunkedMode = false; options.params = params; – Arafat Rahman PAppu Aug 15 '16 at 16:49

1 Answers1

0

Yes. For android the response is null returned but for iOS response is okay.

So for android the work around will be the

response = form.action + params.key;

And following code are enough for sending the file( 4, 5 points are ignored )

var options = new FileUploadOptions();
        options.fileKey = "file";
        options.fileName = fileName;
        options.chunkedMode = false;

        options.params = params;