Skip to content

Instantly share code, notes, and snippets.

@trevorfoskett
Created November 22, 2019 07:18
Show Gist options
  • Save trevorfoskett/c399dc88941f6c9594418f5ae7d17426 to your computer and use it in GitHub Desktop.
Save trevorfoskett/c399dc88941f6c9594418f5ae7d17426 to your computer and use it in GitHub Desktop.
Assign a unique filename to each file.
...
var fileName = file.name;
// Assign a unique name (uFileName) to each file (fileName
// + randnum)to ensure client will not attempt to use same
//set of keys for multiple files of the same name.
var uFileName = `${fileName}|${Math.random()}`;
// Set temporary storage location in /tmp/
var dest = fs.createWriteStream(`/tmp/${uFileName}`);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment