-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Same file upload will upload again with a different name, instead of beeing cache like where only the name is returned #648
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. |
but if i upload same file , it will recreate a new file with the same name。how can i avoid it。 i want to if the file is exist,not create |
You don't need to override internal functions, there's not documented Lines 60 to 70 in 5110ef8
const { formidable } = require('formidable');
const form = formidable({
keepExtensions: true, // that must be `true`
filename: (part) => {
// it has `part.name` and etc
console.log(part);
}
}); And yes, if you implement to have same name, it will probably recreate/rewrite the existing file. One workaround could be to cache the filename in some variable outside, and check if exists ( Sorry about that. Not possible otherwise, for the moment. |
thx @tunnckoCore |
but it sames can not rename according file's md5,part has no unique flag to rename file。
|
Sorry, I can't understand your last comment. Don't feel bad to use something like Google Translate if your English isn't good! 😉 There's nothing wrong :) After a few hours of trying how I can implement what I was thinking and proposing... I gave up, I can't come to a solution, without changes in the codebase. Even if the filename or the contents is always the same it will always overwrite its contents... I still have a feeling I can do it, but I'm not 100% sure and does not worth the time. Fundamentals & codebase are messy, and currently we can't do some things, sorry. |
Sorry, I will use Google Translate. I want to upload the same image only once, and if it exists, it will return the name of the previously generated image (similar to cache) instead of regenerating. I'm not sure if this kind of cache is better? |
Yes, I thought about that but can't think of a solution for now, sorry... :( |
thank you @tunnckoCore |
#689 If you want to prevent duplicate file content but with different name then you have to manually compare file content after file upload and delete one. |
hi, i found same file upload will return different name,and this will create many files, i want upload same file. return the same file,please help me, i found this code
The text was updated successfully, but these errors were encountered: