incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <...@adobe.com>
Subject Re: Progress callbacks for FileTransfer.upload/download: patch in progress
Date Tue, 10 Jul 2012 16:26:05 GMT
Thanks for taking a stab at this! I guess I shouldn't be surprised someone
attempts to fix this judging by the amount of interest on IRC / the JIRA
thread in this feature :)

Here is my feedback:

1. I would add this feature as a top-level FileTransfer event callback.
So, no matter if you fire off upload() or download(), you would get a
progress event. In the spirit of other APIs like the File API, I would
implement it so that users could do something like:

var ft = new FileTransfer();
ft.onprogress = function(evt) {
    if (evt.type == 'upload') {
    } else {
    }
};

We could also reuse a lot of existing javascript in the cordova-js project
[1], as we have an implementation of W3C's ProgressEvent [2]. That said,
this would require a little bit of additional work. Each FileTransfer
instance would need an ID (tie it into the callback ID?), to handle the
case where multiple FileTransfer objects are instantiated and running at
the same time. So, a bunch of effort would still need to go into the
cordova-js project.

2. The Java code referenced in your implementation [3] would need a bit of
rework with the above in mind.
3. Last but certainly not least: platform parity.

With all of the above, I think it would be safe to try to slate this for
after 2.0.

My 2 cents.

[1] 
https://github.com/apache/incubator-cordova-js/blob/master/lib/common/plugi
n/ProgressEvent.js
[2] http://www.w3.org/TR/progress-events/
[3] 
https://github.com/brion/incubator-cordova-android/commit/c8c1769a65535e2ef
1ccf915248ab97ef473ef22

On 7/3/12 3:45 PM, "Brion Vibber" <brion@pobox.com> wrote:

>Consensus seems to be that FileTransfer should get deprecated in favor of
>an XHR2 polyfill, but until that's done there seem to be lots of folks who
>would love to get progress callbacks from FileTransfer (those of us doing
>binary files I think can't rely on current XHR support).
>
>I've whipped up a quick patch for FileTransfer.upload() on Android that
>calls the success callback with progress updates if you opt-in for it with
>a parameter:
>https://issues.apache.org/jira/browse/CB-622?focusedCommentId=13406124#com
>ment-13406124
>
>The current patch is a little sub-ideal in that it uses the options.params
>array and doesn't strip the 'progress' item out; with more polish that
>could be sent as a separate argument. Possibly the JS could be tweaked so
>you can just set a function callback as options.progress?
>
>Please let me know if this sounds sane before I go finishing it up and
>adding support for download and iOS. :)
>
>-- brion vibber (brion @ pobox.com / bvibber @ wikimedia.org)


Mime
View raw message