question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cancel/abort upload process (Feature request)

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
GrosSacASaccommented, Dec 5, 2019

I am on it

2reactions
tunnckoCorecommented, Mar 20, 2020

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 the part.on('data') passed with the this, part, file and the buffer. ry catch inside that loop, and if catch error call this._error. Plus some if check before the file.open() couple lines above.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found