-
Notifications
You must be signed in to change notification settings - Fork 195
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
Custom file names #30
Conversation
@@ -11,7 +11,7 @@ class HeadHandler extends BaseHandler { | |||
* @return {function} | |||
*/ | |||
send(req, res) { | |||
const re = new RegExp('\\' + this.store.path + '\\/(\\w+)\/?'); // eslint-disable-line prefer-template | |||
const re = new RegExp('\\' + this.store.path + '\\/([\\w\-]+)\/?'); // eslint-disable-line prefer-template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added just for that example hashing function from our convo on the issue, right? Maybe it should just match the non-whitespace (\S
) rather than any alphanumeric character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was to match the example function from the issue. I think \S
would be more concise too :)
const upload_metadata = req.headers['upload-metadata']; | ||
|
||
if (upload_length === undefined && upload_defer_length === undefined) { | ||
return reject(412); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These error code/messages should probably be constants, but I can do that in a separate PR :)
Thanks @js3692 !! |
only renames to - hypen without extension. What I need is to save the file to its original name |
User can now provide a hashing function to set a custom file name for each upload. When the hashing function is not provided, it defaults to a random
Uid
.Example:
Assuming the POST request was made to
/files
, the file name will now be'-file'