-
-
Notifications
You must be signed in to change notification settings - Fork 683
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 not to upload with form.parse() ? #609
Comments
Thank you for raising this issue! We will try and get back to you as soon as possible. Please make sure you format it properly, followed our code of conduct and have given us as much context as possible. |
No possible at the moment. It should be in the v2 final. I had some idea about that, I just didn't jump on the code to test it. |
Hello again. I have a question. I'm also using form.parse() for passing
Also, when I call form.parse(), images automatically uploaded on server, but it doesn't work anyway. How can I solve this? should I use .on() and .emit() instead? |
I think the callback to |
thx a lot XD |
I know it is old, but you can overwrite the logic, it's not so hard. import {IncomingForm, Part} from 'formidable';
export class FormParse extends IncomingForm {
private handleFilePart(part: Part) {
let chunks = [];
part.on('data', (chunk) => {
chunks.push(chunk);
});
part.on('end', () => {
this.emit('field', part.name, {
contentType: part.mime,
filename: part.filename,
content: Buffer.concat(chunks)
});
});
}
public onPart(part: Part) {
if (part.filename === undefined) {
this.handlePart(part);
} else {
this.handleFilePart(part);
}
}
} |
I will take a look at this issue during the weekend. |
@GrosSacASac I think this issue is solved by the new option |
This issue is about providing a convenient way of not saving the file. The original issue was about empty files only that is true, but we want more now. |
It's like an option to avoid the file to be saved? In this case why formidable will be used for? Only for parsing the upload file request? I'm missing exactly what you want as formidable feature. |
Yes. In this case formidable will be used to parse "multipart/form-data" correctly. Not saving in a file is useful for:
|
I would even suggest that this should be the default behavior. If the library returns the buffer by default (or stream, it can be flagged), then it is quite easy to save the file on the logical machine. But maybe such changes should be made in version 3. It may be worth removing this logic altogether, which will reduce the package size. Whoever needs it, he himself implements it. |
@xr0master I think to turn this as default now and introduce a breaking change is not worthy, maybe change the defaults in future major versions. |
@leonardovillela I said so, didn't I? But on the other hand, even version 2 has not yet been released. Such changes may well be. |
It's okay to be in v2. The canary doesn't have any (unless u do something very specific) breaking changes anyway.
Yep, sounds good. I imagined some super simple and comfortable-looking (to me) API in v3 #635. Some of these surely can be in v2 i think. A lot of users are using |
I think can be removed as a pinned issue in this repository. |
Context
What problem are you trying to solve?
I have a problem with using formidable, it's a simple but I can't find any site with this problem.
"In case I have a upload webapp with formidable, how not to upload an empty file? It always upload an empty file, title like upload_3f0934128511fd38dha1.... and no content"
I'm using this module like below in expressJS
but it doesn't work anyway. I think
form.parse()
has no option to not upload.So if
form.parse() in formidable
has a function to make webapp upload or not, plz comment below. Or same function with same feature, plz commentthx
The text was updated successfully, but these errors were encountered: