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

Upload progress #243

Closed
gcats opened this issue Oct 9, 2015 · 7 comments
Closed

Upload progress #243

gcats opened this issue Oct 9, 2015 · 7 comments

Comments

@gcats
Copy link

gcats commented Oct 9, 2015

How do I track upload progress in multer?

@LinusU
Copy link
Member

LinusU commented Oct 10, 2015

Track how much of the stream is consumed and compare it to the stated Content-Length.

@gcats
Copy link
Author

gcats commented Oct 10, 2015

and where do I track the stream consumption? multer doesnt have many callback functionalities...

for instance:
app.post('/posts', upload.single('post_file'), function(req, res){
//callback for completed file, but where do I get partial results?
});

@LinusU
Copy link
Member

LinusU commented Oct 10, 2015

This one seems good if you don't want to roll your own: https://www.npmjs.com/package/progress-stream

Pipe req to that one and give it to multer.

var p = progress()
var upload = multer().single('file')

req.pipe(p)
p.headers = req.headers

p.on('progress', _)
upload(p, res, _)

@anand-ma
Copy link

@ Can you give a sample complete working example?
I'm using var upload = multer({storage: storageConfig}) and inject upload.single('alcon') to my route

miro added a commit to miro/kadkad-mgmt that referenced this issue Dec 28, 2015
..sadly the current API implementation doesn't support progress events on upload (see expressjs/multer#243)
superagent-module was upgraded on the previous commit in order to get support for the progress event. Now we "only" need that feature on the API.
@luxp
Copy link

luxp commented Dec 13, 2016

You can try to listen to the event upload.onprogress
This works fine for me. http://stackoverflow.com/a/36725089/6029652

@eoliverio
Copy link

eoliverio commented Nov 21, 2019

This one seems good if you don't want to roll your own: https://www.npmjs.com/package/progress-stream

Pipe req to that one and give it to multer.

var p = progress()
var upload = multer().single('file')

req.pipe(p)
p.headers = req.headers

p.on('progress', _)
upload(p, res, _)

@LinusU
Can you expound this approach?
It seems to be what I need but the progress event only fires once at 100%.

@LinusU
Copy link
Member

LinusU commented Nov 23, 2019

It seems to be what I need but the progress event only fires once at 100%.

I haven't tried that package myself, maybe it's a bug in progress-stream?


Since this isn't specific to Multer, I think it's better to open a post at Stack Overflow were you should be able to get help with this :)

@LinusU LinusU closed this as completed Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants