-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
How reject uploading after checking mimetype #64
Comments
It's a good question, and the answer depends on the situation. If you have multiple files and you don't want one bad one to cancel the entire request, you can use I'm not sure the best way to immediately cancel the uploads to make an early response, but I imagine it may differ depending if you use Koa or Express. There should be a good way to do it though; this was one of the strong use cases for moving to a stream based API. Perhaps someone can help? Eventually I'll have to work this answer out for myself; once I start implementing file uploads in my current project. |
I am using express and I try to stream.destroy() but it failed, busboy keeps working on the remaining data and cause an error. (push after EOF, something like that). Also tried stream.pause before destroy, same result. It will be great if it can stop the upload immd. |
any new IDEA? :) |
Also having this problem. I'd like to bail out without consuming the stream if the |
Hey @nicoosokhan, this will be fixed when #81 gets finished. In a nutshell, we can't respond in HTTP 1.1 until the request is finished, so each file stream needs to be fully consumed. The approach I'm taking in #81 is to buffer all uploads to the filesystem (using temp files) instead of propagating backpressure up to the network. This will also make it much simpler, as you can ignore one upload without blocking another one. @nicoosokhan once this is merged, you can simply ignore the stream, and the temp files will get cleaned up eventually. If you want to prevent an accumulation of temp files, you can simply call: stream.destroy()` where you have |
Hi, Thanks for Repository.
What is the best efficient way to prevent uploading by checking mimetype (or even filename)?
This is my resolver.
After uploading a non 'image/png', I got no response.
Im using apolloUploadKoa
The text was updated successfully, but these errors were encountered: