Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 69A73200C1C for ; Tue, 10 Jan 2017 21:50:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 68423160B2C; Tue, 10 Jan 2017 20:50:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ACEE8160B4B for ; Tue, 10 Jan 2017 21:49:59 +0100 (CET) Received: (qmail 21777 invoked by uid 500); 10 Jan 2017 20:49:58 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 21741 invoked by uid 99); 10 Jan 2017 20:49:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jan 2017 20:49:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 8D3E52C03DE for ; Tue, 10 Jan 2017 20:49:58 +0000 (UTC) Date: Tue, 10 Jan 2017 20:49:58 +0000 (UTC) From: "Michael Stanford (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (CB-12257) xhr.send fails on Cordova File object - maybe because it's not an instanceof Blob? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 10 Jan 2017 20:50:00 -0000 [ https://issues.apache.org/jira/browse/CB-12257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michael Stanford resolved CB-12257. ----------------------------------- Resolution: Not A Problem Used the FileTransfer plugin instead. > xhr.send fails on Cordova File object - maybe because it's not an instanceof Blob? > ---------------------------------------------------------------------------------- > > 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, my test app successfully retrieves a File object in every case from the local file system. > In each of the three cases, the app invokes the Amazon S3 Javascript API upload method with this File object. In desktop Safari the file uploads correctly and appears in the S3 bucket correctly. > In the Cordova apps, both iOS and Android, the file seems to upload correctly (no errors), but the resulting (correctly named) file in the bucket contains only the 15-byte text string "\[object Object\]". > The app uses the same HTML and JS source files in all three cases; after creating the File object the code is identical, and because they run from the same HTML page, the meta information is also the same. > Because the S3 API upload method supports multipart uploads, it invokes the File.slice method on the File before passing it to xhr.send. In the desktop Safari implementation of the File object, the slice method returns a Blob object. In the Cordova implementation (as documented in the source code at line 47 of File.js) it returns another File object. > Tracing through to the xhr.send function in the S3 API, the desktop version delivers a Blob as the argument to xhr.send(), and the file is uploaded correctly. The Cordova versions deliver a File as the argument to xhr.send(), and the uploads fail. > Although the File object in desktop Safari is an instanceof Blob, the Cordova File object is not an instanceof Blob, which might explain why xhr.send can't cope with it. > {code} > > params.Body instanceof File > < true > > params.Body instanceof Blob > < true > {code} > {code} > > params.Body instanceof File > < true > > params.Body instanceof Blob > < false > {code} > The documentation here (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send) indicates that xhr.send can handle a Blob, but doesn't mention a 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