I was able to use changeFileInfo.ID in the pre-create hook to change the name of the uploaded file.
I tried adding a folder structure into the ID and it did not work. e.g.
changeFileInfo.ID = “foldername/filename.ext”;
Should this work? Can support be added for it? Is there a way for me to do it on my own?
I know the generally accepted way to implement a custom file name is via the post-create hook and to move/rename the file directly in the storage. In Azure, this requires a copy + delete of the file … there is no “move” or “rename” method. The copy can be an expensive operation for large files and we’d like to avoid this solution if possible.
There is no intentional limitation that should prevent this from working in tusd. What do you mean exactly by “it did not work”? Did an error appear? Please provide more details.
reExtractFileID = regexp.MustCompile(`([^/]+)\/?$`)
...
result := reExtractFileID.FindStringSubmatch(url)
This regex will only capture the last part of the path … the file name.
What we’d want to do is strip the base url, ending in a slash, from the beginning of url, and strip any trailing slashes, to allow for file ids that contain a slash.
this is more involved than just the regex as we need to adjust the request routing as well. We must be very careful as this should easily introduce regressions in some edge cases.
Yeah, I am not surprised this is more complicated … forward slash handling can definitely be finicky in web applications. This does seem like something that would be of value for the different stores.
I’ve never worked with Go before so not sure how much help I can be at this point.
When do you think you might get around to merging a fix? And then issuing the next release? A very rough guesstimate is acceptable
It seems like tusd accepts the custom file correct, and saves the info file correctly in Azurite … but when it tries to immediately request the info file, the value is escaped incorrectly.
The problem seems like there is a “narrow no break space” character in the file name (this file name came directly from my Mac). %E2%80%AF is what it looks like URL encoded.
If I want to set the file ID to the filename, should I only allow certain characters?
You should only use URL-safe character in the upload ID because it will end up in the URL. tusd should probably have a safety check for this included, I agree.