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

isuue (stop downloading if file size is big) #371

Closed
NobodyLR opened this issue Feb 24, 2016 · 4 comments
Closed

isuue (stop downloading if file size is big) #371

NobodyLR opened this issue Feb 24, 2016 · 4 comments

Comments

@NobodyLR
Copy link

i am using formidable to uplaod a file
i am setting a max file size
what i would like is to stop the uplaod if the file that i am expecting is too big
i am using this code but i dont like it its ugly

form.on('progress', function(bytesReceived, bytesExpected) {
if(bytesExpected/1024/1024>100)//100Mo
req.connection.destroy();

i am not using on('file) or the form.parse cuz the callback is executed after the file is uploaded
and this is what i dont like

the code that i am using does the trick but it makes an errer on the client side(angularjs)
if there is a way to stop the uplaod and send a json to the client
ty

@marckris
Copy link

marckris commented May 13, 2016

AFAIK Formidable doesn't provide a way to stop the uploading process so req.connection.destroy() seems to be the only way around it for now.

I'm currently using Node v6.0.0 and Formidable 1.0.17 and this is how I use it:

http://stackoverflow.com/a/37201347/1777999

@tunnckoCore
Copy link
Member

tunnckoCore commented Jan 16, 2017

@marckris great example. I believe it can be implemented with same on('progress') handler internally. And also maybe would be good to emit/trigger some event when it happens.

@NobodyLR thanks for the report.

edit: marked as feature for future releases

@xarguments
Copy link
Collaborator

Seems to be implemented as max file size option.
See maxFileSize option here: https://github.com/felixge/node-formidable#formidableincomingform

Other part is in another request: #471

@NobodyLR, So if there is no other case for this, its going to be closed soon.

@tunnckoCore
Copy link
Member

Seems to be implemented as max file size option.

The point was to allow abort/cancel which is the #471.

I'm agree with closing, lets keep track on #471 and reference to it.

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

4 participants