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
Ability to specify prefix for S3 storage #17
Conversation
Just a few questions that arose in my mind:
|
@eprikazc how do i use this? Do you have documentation for this? Thanks! I did something similar :
into S3Storage instead to get this to work. When I configure my depot,I used the depot name as the upload directory ... |
@rlam3 - see eprikazc@acc85ae |
That was one of the reasons why I was concerned about subclassing, it would be a bit confusing for users :D Maybe we can expose a Factory to provide a single name while bulding the different classes? Not sure the improvement in usability justifies the effort of having the factory and maintaining it on long-term. Your opinion? |
@eprikazc So I'm assuming that you are doing something along the lines of
Am I correct? If that is the case, why do you need to subclass? why not just add it right into S3Storage? |
This reverts commit dacae09.
👍 far better approach. I think that we can rename the bucket_driver as an internal variable (_bucket_driver), update the S3Storage docstring to document the prefix option and then we are ready to merge 😄 |
Done! |
Ability to specify prefix for S3 storage
Is this how I configure it?
|
Yes. Though, I think prefix should be "photos/". Any problems with it? |
Documentation show that it should be outside of the config dictionary... Could you please verify and correct this if it is wrong? Thanks! http://depot.readthedocs.org/en/latest/api.html#depot.manager.DepotManager |
You are confusing the configuration prefix with the S3Storage key prefix -> http://depot.readthedocs.org/en/latest/api.html#depot.io.awss3.S3Storage Just pass a prefix key in the options of the DepotManager when using S3Storage to specifiy an S3 key prefix. |
@amol- Correct me if I'm wrong. DepotManager prefix is used for the prefix of the configuration dictionary that is passed in. Thanks |
@rlam3 yes, that's it |
This change adds S3PrefixedStorage class which extends S3Storage with "prefix" required argument.
I thought it would be nice to be ale to store all files within one folder in S3. So, I implemented it after reviewing this discussion:
https://github.com/amol-/depot/issues/13#issuecomment-142432557
As suggested, prefix here is set in storage, not in the file field.
Can you please review and provide feedback? One thing I am not sure about in this implementation is that prefix ends up in UploadedFile['file_id']. Perhaps it would be more clear to not leak prefix outside of the storage class.