You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Vincent Pizzo (JIRA)" <ji...@apache.org> on 2014/05/03 03:46:17 UTC

[jira] [Comment Edited] (CB-200) FileTransfer should support uploading multiple files in one HTTP request

    [ https://issues.apache.org/jira/browse/CB-200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13988521#comment-13988521 ] 

Vincent Pizzo edited comment on CB-200 at 5/3/14 1:45 AM:
----------------------------------------------------------

Just posting this in case anyone wants a quick workaround using xhr2 to upload multiple files (sorry the example is in coffeescript and most error handling is taken out but the general gist is there)

{code:title=xhr.coffee|borderStyle=solid}
formData = new FormData()
window.resolveLocalFileSystemURL fileUri, (fileEntry) ->
  fileEntry.file (file) ->
    reader = new FileReader()
    reader.onloadend = (fileReadResult) ->
      data = new Uint8Array fileReadResult.target.result
      formData.append 'formParamKey', new Blob([data], type: file.type), file.name
      xhr = new XMLHttpRequest()
      xhr.open 'POST', url, true
      xhr.send formData
    reader.readAsArrayBuffer file
{code}


was (Author: vincentjames501):
Just posting this in case anyone wants a quick workaround using xhr2 to upload multiple files (sorry the example is in coffeescript and most error handling is taken out but the general gist is there)

formData = new FormData()
window.resolveLocalFileSystemURL fileUri, (fileEntry) ->
  fileEntry.file (file) ->
    reader = new FileReader()
    reader.onloadend = (fileReadResult) ->
      data = new Uint8Array fileReadResult.target.result
      formData.append 'formParamKey', new Blob([data], type: file.type), file.name
      xhr = new XMLHttpRequest()
      xhr.open 'POST', url, true
      xhr.send formData
    reader.readAsArrayBuffer file


> FileTransfer should support uploading multiple files in one HTTP request
> ------------------------------------------------------------------------
>
>                 Key: CB-200
>                 URL: https://issues.apache.org/jira/browse/CB-200
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: Plugin File Transfer
>    Affects Versions: 1.3.0
>         Environment: Windows XP, Android, Lenovo ThinkPad
>            Reporter: Matt Accola
>            Assignee: Andrew Grieve
>            Priority: Trivial
>
> FileTransfer only allows one file to be uploaded at a time. Should allow multiple files to be uploaded at once.
> This might be necessary if the server-side service requires all files to be submitted at once to ensure any operations on the files are atomic.
> This question has been asked on the phonegap Google Group, http://groups.google.com/group/phonegap/browse_thread/thread/bdc40098c2954870.
> (Update: Since this requires a UI change for parity, I've added more components and moved it out of 1.7.  This should be added to the Roadmap, so I'm leaving it assigned to myself so I'm reminded to do this - Joe)



--
This message was sent by Atlassian JIRA
(v6.2#6252)