Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for providing file upload progress. #373

Conversation

aaron-blondeau-dose
Copy link
Contributor

@aaron-blondeau-dose aaron-blondeau-dose commented Nov 5, 2016

It would be very convenient if developers could get progress when uploading a file with Parse.File. The use case would look something like this:

var parseFile = new Parse.File(file.name, file);
parseFile.save({
    progress: (value) => {
        console.log("TODO show progress to user : "+value);
    }
}).then();

See also https://www.parse.com/questions/file-upload-progress-javascript-api

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@doender
Copy link

doender commented Dec 20, 2016

Will this be merged?

@tommy-b-10
Copy link

Just wondering when this will be merged?

@jcguarinpenaranda
Copy link
Contributor

Please merge this!!

@flovilmart
Copy link
Contributor

@aaron-blondeau-dose Thanks for the PR, could you fix the conflicts so we can get that one in for the next release?

@flovilmart
Copy link
Contributor

@aaron-blondeau-dose ping?

@flovilmart
Copy link
Contributor

@aaron-blondeau-dose I'm doing some cleanup here, it seems that it diverged a lot since your PR, are you still interested at getting this one in?

@dplewis
Copy link
Member

dplewis commented Nov 30, 2018

@flovilmart I can help out with this

@codecov
Copy link

codecov bot commented Nov 30, 2018

Codecov Report

Merging #373 into master will decrease coverage by 0.13%.
The diff coverage is 47.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   85.82%   85.69%   -0.14%     
==========================================
  Files          48       48              
  Lines        3915     3928      +13     
  Branches      892      898       +6     
==========================================
+ Hits         3360     3366       +6     
- Misses        555      562       +7
Impacted Files Coverage Δ
src/ParseFile.js 95.23% <100%> (+0.95%) ⬆️
src/RESTController.js 80.71% <35.29%> (-4.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 686ce43...82970fb. Read the comment docs.

@dplewis
Copy link
Member

dplewis commented Nov 30, 2018

@flovilmart @acinader Quick update on this.

This will only work in the browser. I haven't tried it on IE8 / IE9.

The xmlhttprequest node package seems to be missing the progress event. I would do a PR to add support for it but it seems like that package isn't well maintained.

https://github.com/driverdan/node-XMLHttpRequest

What do you think?

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good. I think its fine to add for just browser.

src/ParseFile.js Outdated
* * Valid options are:<ul>
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
* be used for this request.
* <li>progress: Callback for upload progress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add a note here that progress is only supported in the browser

@@ -6,17 +6,20 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

/* global File */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this?

@@ -183,6 +186,22 @@ describe('ParseFile', () => {
expect(a.equals(b)).toBe(false);
expect(b.equals(a)).toBe(false);
});

it('reports progress during save when source is a File', () => {
const file = new ParseFile('progress.txt', new File(["Parse"], "progress.txt"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acinader /* global File */ is for the new File(...) so that it can find it.

@kartheeknagasuri
Copy link

kartheeknagasuri commented Dec 2, 2019

@dplewis
what's the correct usage of progress call back? I am using like this and not getting any progress call back

var parseFile = new Parse.File(file.name, file);
parseFile.save({
progress: (value) => {
console.log("TODO show progress to user : "+value);
}
}).then();

@dplewis
Copy link
Member

dplewis commented Dec 2, 2019

@kartheeknagasuri That is correct. This feature is for the browser only.

@kartheeknagasuri
Copy link

@dplewis I am trying through the browser, but not getting the call back, not sure what's the problem

@ladigitale
Copy link

The progress calback seems to be ran just one time with value 1.
I'm trying the upload of files (size about 1Mo) with a slow network in order to follow the evolution

@aliasad106
Copy link

Doesn't work, Any progress on this ?

@mtrezza
Copy link
Member

mtrezza commented Aug 13, 2022

If there is an issue with this feature, please open a new issue (if it doesn't exist already) to report a bug.

@parse-community parse-community locked and limited conversation to collaborators Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet