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.
Introduction
This is probably a crazy idea, but I needed s3proxy to be able to rename the names of the blobs before they were written, so I have developed this middleware, and I am sharing it in case it might be useful to someone else.
Use case
In our case, we have a product that can only talk to S3, uploading blobs in a very limited way, with almost no configuration. Originally, blobs were uploaded to /prefix/<source>/<YYYYYY>/<MM>/<DD> (e.g. /prefix/typea/2023/01/31). But due to other integrations that are not relevant, we needed the blobs to be uploaded in a path with the following format:
/prefix/date=<YYYY>-<MM>-<DD>/type=<source>
Configuration of middleware
The regex is configured as:
s3proxy.regex-blobstore.match.<regex name> = <regex match expression>
s3proxy.regex-blobstore.replace.<regex name> = <regex replace expression>
You can use multiple regex, and they are evaluated in order. The first regex that matches breaks the evaluation.
For example, for the use case previously mentioned, we have the following rule:
I would love to have your feedback regarding this middleware, as well as possible things I might have overlooked when implementing it.
Thank you very much for your project.