You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Gord Tanner <go...@tinyhippos.com> on 2012/06/22 22:15:52 UTC
Enlighten me on the point of the FileTransfer API
Looking at:
http://docs.phonegap.com/en/1.8.1/cordova_file_file.md.html#FileTransfer
I am wondering why we need to go to native for this API and what the use
case is for it?
Why wouldn't we just end up routing these calls to an XHR form post in the
browser? (and XHR for download).
Gord
Re: Enlighten me on the point of the FileTransfer API
Posted by Jesse <pu...@gmail.com>.
Currently if you want to download an image without the FileTransfer API you
would have to :
- load the image with a DOM Image element, and listen for the load event
- render it into a canvas
- request the base64 encoded data from the canvas
- save it to file with the File API as base64 encoded data
Then every time you want to display it :
- load it with XHR or File API
- assign it's data to the src of an image
Being able to Download and Save to the file system on the native side will
prevent having to constantly convert between binary + base64.
I think that the FileTransfer API will still be relevant even after XHR2 is
ubiquitous because it is much friendlier on memory, and could even support
file-streaming uploads.
Ultimately FileTransfer will be a plugin like everything else, but I don't
see it going anywhere because of the availability of XHR2. I would even
like to see additions to the API to manage an upload/download queue, and
possibly support background filetransfers as well. Download throttling
based on bandwidth availability or battery, ...
On Sat, Jun 23, 2012 at 10:42 AM, Brian LeRoux <b...@brian.io> wrote:
> Heh!
>
> On Friday, June 22, 2012, Jesse MacFadyen wrote:
>
> > FileTransfer makes lots of sense!
> > Think binary.
> >
> > Cheers,
> > Jesse
> >
> >
> > On 2012-06-22, at 5:50 PM, Dave Johnson <dave.c.johnson@gmail.com
> <javascript:;>>
> > wrote:
> >
> > > Yah it's essentially xhr2.
> > >
> > > Android < 4 (amongst others) doesn't have xhr2 tho.
> > >
> > > On Friday, June 22, 2012, Gord Tanner wrote:
> > >
> > >> Looking at:
> > >>
> > http://docs.phonegap.com/en/1.8.1/cordova_file_file.md.html#FileTransfer
> > >>
> > >> I am wondering why we need to go to native for this API and what the
> use
> > >> case is for it?
> > >>
> > >> Why wouldn't we just end up routing these calls to an XHR form post in
> > the
> > >> browser? (and XHR for download).
> > >>
> > >> Gord
> > >>
> >
>
--
@purplecabbage
risingj.com
Re: Enlighten me on the point of the FileTransfer API
Posted by Brian LeRoux <b...@brian.io>.
Heh!
On Friday, June 22, 2012, Jesse MacFadyen wrote:
> FileTransfer makes lots of sense!
> Think binary.
>
> Cheers,
> Jesse
>
>
> On 2012-06-22, at 5:50 PM, Dave Johnson <dave.c.johnson@gmail.com<javascript:;>>
> wrote:
>
> > Yah it's essentially xhr2.
> >
> > Android < 4 (amongst others) doesn't have xhr2 tho.
> >
> > On Friday, June 22, 2012, Gord Tanner wrote:
> >
> >> Looking at:
> >>
> http://docs.phonegap.com/en/1.8.1/cordova_file_file.md.html#FileTransfer
> >>
> >> I am wondering why we need to go to native for this API and what the use
> >> case is for it?
> >>
> >> Why wouldn't we just end up routing these calls to an XHR form post in
> the
> >> browser? (and XHR for download).
> >>
> >> Gord
> >>
>
Re: Enlighten me on the point of the FileTransfer API
Posted by Jesse MacFadyen <pu...@gmail.com>.
FileTransfer makes lots of sense!
Think binary.
Cheers,
Jesse
On 2012-06-22, at 5:50 PM, Dave Johnson <da...@gmail.com> wrote:
> Yah it's essentially xhr2.
>
> Android < 4 (amongst others) doesn't have xhr2 tho.
>
> On Friday, June 22, 2012, Gord Tanner wrote:
>
>> Looking at:
>> http://docs.phonegap.com/en/1.8.1/cordova_file_file.md.html#FileTransfer
>>
>> I am wondering why we need to go to native for this API and what the use
>> case is for it?
>>
>> Why wouldn't we just end up routing these calls to an XHR form post in the
>> browser? (and XHR for download).
>>
>> Gord
>>
Re: Enlighten me on the point of the FileTransfer API
Posted by Dave Johnson <da...@gmail.com>.
Yah it's essentially xhr2.
Android < 4 (amongst others) doesn't have xhr2 tho.
On Friday, June 22, 2012, Gord Tanner wrote:
> Looking at:
> http://docs.phonegap.com/en/1.8.1/cordova_file_file.md.html#FileTransfer
>
> I am wondering why we need to go to native for this API and what the use
> case is for it?
>
> Why wouldn't we just end up routing these calls to an XHR form post in the
> browser? (and XHR for download).
>
> Gord
>