You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Michael Stanford (JIRA)" <ji...@apache.org> on 2016/12/16 07:33:58 UTC

[jira] [Updated] (CB-12257) xhr.send fails on sliced File object

     [ https://issues.apache.org/jira/browse/CB-12257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Stanford updated CB-12257:
----------------------------------
    Description: 
Versions:
Cordova: 6.4.0
Cordova File System Plugin: 4.3.1

iOS: 10.0.2
Cordova iOS: 4.3.1

Android: 6.0.1
Cordova Android: 6.0.0

Desktop OS: OS X 10.12.1
Desktop Safari: 10.0.1

AWS S3 SDK is documented at:
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3/ManagedUpload.html

On both Android and iOS, using the Cordova File System plugin, and in OS X Safari using the File Input HTML tag, I seem to be successfully retrieving a File/blob in every case - see the listings below.

In each of the three cases, I invoke the Amazon S3 SDK upload API with this File object. In desktop Safari the file uploads correctly and appears in the S3 bucket correctly. 

In iOS and Android, the file appears to upload correctly (no errors), but all that appears in the bucket is the 15-byte text string "\[object Object\]".

I am using the same HTML and JS files  in all three cases; after collecting the File object the code is identical, and because they run from the same HTML page, the meta information is also the same.

In case it is something to do with security settings, I set all the permissions and CORS on the S3 bucket to wide open for anybody to do anything. This may still be the root of the problem, but the filename gets through OK, and gets written in every case, and the file contents gets through correctly from the desktop browser. 

Tracing through to the xhr.send function in the S3 API, the file is delivered correctly when the argument is a Blob (as delivered by the desktop version), but fails whe the argument is a File object (as delivered by the Cordova version). It seems as though xhr.send understands the Blob, but not the File.


  was:
Versions:
Cordova: 6.4.0
Cordova File System Plugin: 4.3.1

iOS: 10.0.2
Cordova iOS: 4.3.1

Android: 6.0.1
Cordova Android: 6.0.0

Desktop OS: OS X 10.12.1
Desktop Safari: 10.0.1

AWS S3 SDK is documented at:
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3/ManagedUpload.html

On both Android and iOS, using the Cordova File System plugin, and in OS X Safari using the File Input HTML tag, I seem to be successfully retrieving a File/blob in every case - see the listings below.

In each of the three cases, I invoke the Amazon S3 SDK upload API with this File object. In desktop Safari the file uploads correctly and appears in the S3 bucket correctly. 

In iOS and Android, the file appears to upload correctly (no errors), but all that appears in the bucket is the 15-byte text string "\[object Object\]".

I am using the same HTML and JS files  in all three cases; after collecting the File object the code is identical, and because they run from the same HTML page, the meta information is also the same.

In case it is something to do with security settings, I set all the permissions and CORS on the S3 bucket to wide open for anybody to do anything. This may still be the root of the problem, but the filename gets through OK, and gets written in every case, and the file contents gets through correctly from the desktop browser. 

So I am inclined to think that the File/Blob from Cordova behaves differently somehow than the File/Blob from Safari, and returns the string "\[object Object\]" in response to the method that the S3 API uses to retrieve an array buffer.

Here are listings from the Safari Debugger, showing the file objects from the desktop Safari and the Cordova iOS:
{code}
Params:
  ACL: "public-read"
  Body: File
    lastModified: 1477360985000
    name: "gricon.png"
    size: 57742
    type: "image/png"
  File Prototype
    constructor: function()
    lastModified
    name
  Blob Prototype
    constructor: function()
    size
    slice([start], [end], [contentType])
    type
  Object Prototype
  Bucket: "my bucket name"
  ContentType: "image/png"
  Key: "gricon.png"
{code}

{code}
Params:
  ACL: "public-read"
  Body: File
    end: 526048
    lastModified: 1481831134000
    lastModifiedDate: 1481831134000
    localURL: "cdvfile://localhost/temporary/cdv_photo_033.jpg"
    name: "cdv_photo_033.jpg"
    size: 526048
    start: 0
    type: "image/jpeg"
  File Prototype
    constructor: function(name, localURL, type, lastModifiedDate, size)
    slice(start, end)
  Object Prototype
  Bucket: "my bucket name"
  ContentType: "image/jpeg"
  Key: "cdv_photo_033.jpg"
{code}


        Summary: xhr.send fails on sliced File object  (was: Puts [object Object] as file contents in S3 Bucket using Amazon S3 Managed Uploader API)

> xhr.send fails on sliced File object
> ------------------------------------
>
>                 Key: CB-12257
>                 URL: https://issues.apache.org/jira/browse/CB-12257
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 4.3.1
>         Environment: Cordova iOS, Android.
>            Reporter: Michael Stanford
>
> Versions:
> Cordova: 6.4.0
> Cordova File System Plugin: 4.3.1
> iOS: 10.0.2
> Cordova iOS: 4.3.1
> Android: 6.0.1
> Cordova Android: 6.0.0
> Desktop OS: OS X 10.12.1
> Desktop Safari: 10.0.1
> AWS S3 SDK is documented at:
> http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3/ManagedUpload.html
> On both Android and iOS, using the Cordova File System plugin, and in OS X Safari using the File Input HTML tag, I seem to be successfully retrieving a File/blob in every case - see the listings below.
> In each of the three cases, I invoke the Amazon S3 SDK upload API with this File object. In desktop Safari the file uploads correctly and appears in the S3 bucket correctly. 
> In iOS and Android, the file appears to upload correctly (no errors), but all that appears in the bucket is the 15-byte text string "\[object Object\]".
> I am using the same HTML and JS files  in all three cases; after collecting the File object the code is identical, and because they run from the same HTML page, the meta information is also the same.
> In case it is something to do with security settings, I set all the permissions and CORS on the S3 bucket to wide open for anybody to do anything. This may still be the root of the problem, but the filename gets through OK, and gets written in every case, and the file contents gets through correctly from the desktop browser. 
> Tracing through to the xhr.send function in the S3 API, the file is delivered correctly when the argument is a Blob (as delivered by the desktop version), but fails whe the argument is a File object (as delivered by the Cordova version). It seems as though xhr.send understands the Blob, but not the File.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org