[ https://issues.apache.org/jira/browse/CB-13054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16193896#comment-16193896 ]
ASF GitHub Bot commented on CB-13054: ------------------------------------- Github user audreyso commented on a diff in the pull request: https://github.com/apache/cordova-docs/pull/746#discussion_r143080350 --- Diff: www/_posts/2017-10-02-from-filetransfer-to-xhr2.md --- @@ -0,0 +1,85 @@ +--- +layout: post +author: + name: Fil Maj + url: https://twitter.com/filmaj +title: "Transition off of cordova-plugin-file-transfer" +categories: blog +tags: plugins +--- + +Early on in Cordova's existence, the [file-transfer plugin](https://github.com/apache/cordova-plugin-file-transfer) +was created to solve the [problem of downloading binary files](https://issues.apache.org/jira/browse/CB-22). +At the time, there weren't great options for solving this using standards-compliant +web APIs. The web took a twisty path to get to a solution (see +[Firefox's `sendAsBinary`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/sendAsBinary) +and the now-defunct [FileSystem API](https://dev.w3.org/2009/dap/file-system/file-dir-sys.html)'s +[BlobBuilder](https://developer.mozilla.org/en-US/docs/Web/API/BlobBuilder), +among others), but today you can use our good friend [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest)'s +newest features, combined with some newer JavaScript types and objects, to solve +this problem. As a result, +[Cordova is sunsetting the file-transfer plugin](https://issues.apache.org/jira/browse/CB-13052). +All of us at Apache Cordova don't want to leave y'all hanging, though, so we +thought it'd be a good idea to show you how to use these newer XHR features to do +what file-transfer lets you do, but in a way that will work in any modern web +browser to boot! + +## TL;DR + +Don't care about "standards" and all that mumbo jumbo? Just looking to copy-paste +your way to future-proofness? Fine, you'll need this: + +* MDN has a great overview on [Sending and Receiving Binary Data](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data). +* Check out my [little proof-of-concept app](https://github.com/filmaj/xhr2test). + Some details: + * It [uses](https://github.com/filmaj/xhr2test/blob/master/www/js/index.js#L31) + [localforage](https://github.com/localForage/localForage) as a storage abstraction. + * The [`helpers.js` file](https://github.com/filmaj/xhr2test/blob/master/www/js/helpers.js) + has two methods you'll need: + * [`download_blob_via_xhr`](https://github.com/filmaj/xhr2test/blob/master/www/js/helpers.js#L59) + * [`upload_blob_via_xhr`](https://github.com/filmaj/xhr2test/blob/master/www/js/helpers.js#L42) + +## The Long Version + +If you want to understand some of the nuts and bolts enabling binary data transfering, --- End diff -- transferring* :) > Write blog post on how to transition from file-transfer to XHR2 > --------------------------------------------------------------- > > Key: CB-13054 > URL: https://issues.apache.org/jira/browse/CB-13054 > Project: Apache Cordova > Issue Type: Sub-task > Components: cordova-plugin-file-transfer > Reporter: Filip Maj > Assignee: Filip Maj > Labels: plugins-next > > Based on XHR2 research (see linked-to JIRA issue), write up a blog post! -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org