Cancel/abort upload process (Feature request)
See original GitHub issueWhen the lib receives files and fields, it starts to receive (upload) files in any case. For example, I check form fields for emptiness, and reject the request. But it still accepts the files and stores them, and I can’t prevent it.
form.on("field", function (name, value) {
// Reject if a form field value is empty
if (_.isEmpty(value)) {
return res.sendStatus(400);
// Want to cancel processing of the form here, but the lib continues
}
});
form.on("file", function (name, value) {
// And accepts the file, stores it, and reaches here
});
So in this example, if the received form consists of an empty field, and a file, its not possible to stop the file from being accepted (correct me if I’ve mistaken).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:16 (11 by maintainers)
Top Results From Across the Web
How to cancel/abort upload in Dropzone.js if condition is not ...
The accepted answer works if you want to remove the file completely; however, if you want to give the user the option to...
Read more >@opengovsg/ng-file-upload - npm
An AngularJS directive for file upload using HTML5 with FileAPI polyfill for unsupported browsers. Latest version: 12.2.15, last published: ...
Read more >Feature Request Template: How to Manage Suggestions at ...
Streamline and organize user feedback with this free feature request template. Available in Google Docs and Sheets (no email required).
Read more >Feature Request: upload file(s) via generated public link
Cerberus FTP server has a great feature of generating a public link so the end user can download a file without logging in....
Read more >ImgBB — Upload Image — Free Image Hosting
Free image hosting and sharing service, upload pictures, photo host. Offers integration solutions for uploading images to forums.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am on it
Okay, I think the easiest and cleanest approach for now is the “file methods
noop
-ing” (file.open = () => {}
& etc), so it woundn’t even create a writeStream in first place.Other future approach could Validators API, like
options.validators = []
and then calling them from thepart.on('data')
passed with the this, part, file and the buffer. ry catch inside that loop, and if catch error callthis._error
. Plus someif
check before thefile.open()
couple lines above.