cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From audreyso <...@git.apache.org>
Subject [GitHub] cordova-docs pull request #746: CB-13054: blog post on how to move off of fi...
Date Thu, 05 Oct 2017 23:19:44 GMT
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* :)


---

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


Mime
View raw message