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.

Same file upload will upload again with a different name, instead of beeing cache like where only the name is returned

See original GitHub issue

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

IncomingForm.prototype._uploadPath = function(filename) {
  var buf = crypto.randomBytes(16);
  var name = 'upload_' + buf.toString('hex');

  if (this.keepExtensions) {
    var ext = path.extname(filename);
    ext     = ext.replace(/(\.[a-z0-9]+).*/i, '$1');

    name += ext;
  }

  return path.join(this.uploadDir, name);
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
GrosSacASaccommented, Mar 11, 2021

https://github.com/node-formidable/formidable/pull/689 Try the branch, and use the changed filename option. Inside you can sync check existing filenames you have.

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.

1reaction
banli17commented, Jun 27, 2020

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Files are appended together when uploading two different ...
If you upload same file again with same Upload-Key it will get append together. The state of previous upload is fetched from cache...
Read more >
I've replaced an existing asset with a new file, but my site or ...
If the asset was already in use in your application or website, when accessing existing URLs for that asset, you may still see...
Read more >
How to detect input type=file "change" for the same file?
This will reset all fields to default values, but in many cases you may be only using the input type='file' in a form...
Read more >
Microsoft Office Upload Center
Microsoft Office Upload Center now gives you a way to see the state of files you're uploading to a server, in one location....
Read more >
Invalidating files - Amazon CloudFront
Invalidate the file from edge caches. The next time a viewer requests the file, CloudFront returns to the origin to fetch the latest...
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