Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, tusd maintainers and community,
In our organization, we employ a tenant structure akin to GitHub or GitLab, where we have organizations containing multiple projects. Each project can upload assets using tusd.
To efficiently manage permissions and quotas on files, we would like to incorporate the
project_id
into the file path of each asset. For example, the desired format isassets/<project_id>/<asset_id>/filename.png
.In order to achieve this, we needed to modify the file ID within
fileInfo
beforehand. Furthermore, we had to override theExtractIDFromPath
to align with our use case.We have initially implemented this in a fork. However, we believe that integrating this enhancement into the core library would be beneficial for other users who might have similar use cases requiring flexible path customization.
Proposed Changes:
Allow passing a custom function for
ExtractIDFromPath
in the configuration, which can be used to customize how file IDs are extracted from URLs.Update references to
ExtractIDFromPath
to use the custom function if provided, else default to the existing implementation.These changes are backward compatible and allow for greater flexibility in accommodating various file path structures.
We kindly ask for your review and consideration in integrating these changes into the core library.
Special Thanks:
Big shoutout to the tusd maintainers and contributors! You guys rock for keeping this library on point. It's great that we can just plug in your library and rely on it working rock solid. Keep up the awesome work! 👏
Best regards,
Moritz
Summary of Code Changes:
pkg/handler/config.go
: AddedExtractIDFromPath
to the Config struct.pkg/handler/unrouted_handler.go
: Various changes to referenceExtractIDFromPath
from Config and to pass file information by reference.