-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add ability to set acl and object_options per upload #14
Conversation
This builds on Shrine’s `upload_options` plugin: https://github.com/janko-m/shrine/blob/864528eac0c3182f6c553b227535901d69b682c6/lib/shrine/plugins/upload_options.rb
Thanks for this PR! Do you think we could do something like this: class ImageUploader < Shrine
plugin :upload_options, store: {
acl: "publicRead",
cache_control: 'public, max-age: 7200',
}
... This means we treat the # Current implementation
storage = Shrine::Storage::GoogleCloudStorage.new(
bucket: 'my-bucket',
cache_control: 'public, max-age: 7200',
default_acl: 'publicRead',
)
# Proposal
storage = Shrine::Storage::GoogleCloudStorage.new(
bucket: 'my-bucket',
cache_control: 'public, max-age: 7200',
acl: 'publicRead',
) @janko-m any opinion here? (sorry to tag you on those issues, but I prefer to be consistent with the other plugins and Shrine conventions) |
@renchap Np, I always like to help with conventions if I can. The way that First, all options passed to s3 = Shrine::Storage::S3.new(upload_options: {acl: "public-read", ...}) The s3.upload(io, id, acl: "private")
# or
Shrine.plugin :upload_options, store: {acl: "private"} I prefer @renchap's suggestion of keeping the upload options flat instead of introducing the |
Hi guys, great work with shrine and GCS, I'm a fan. @renchap I agree with your proposal so I've gone ahead and updated the PR. Just so we're on the same page, I originally reused the existing # Actual current implementation
storage = Shrine::Storage::GoogleCloudStorage.new(
bucket: 'my-bucket',
object_options: { cache_control: 'public, max-age: 7200' },
default_acl: 'publicRead',
) As you've recommended, I've changed it to # In PR
storage = Shrine::Storage::GoogleCloudStorage.new(
bucket: 'my-bucket',
acl: 'publicRead',
cache_control: 'public, max-age: 7200'
) This should will still support other http headers like |
Also note that this will be a breaking change for existing users of |
@dimroc Actually, I only agree with the first part of @renchap's suggestion about keeping upload options in In |
Regarding changes to Shrine::Storage::GoogleCloudStorage.new(
bucket: "store",
upload_options: {
acl: 'publicRead',
cache_control: 'public, max-age: 7200'
},
) as opposed to the existing approach Shrine::Storage::GoogleCloudStorage.new(
bucket: "store",
default_acl: 'publicRead',
object_options: {
cache_control: 'public, max-age: 7200'
},
) |
I just merged #16 which switches to |
Looks good to me. I updated to the new version and it all checks out. |
This builds on Shrine’s
upload_options
plugin as further described here:https://github.com/janko-m/shrine/blob/864528eac0c3182f6c553b227535901d69b682c6/lib/shrine/plugins/upload_options.rb
Allowing the following:
ACL can now be set per uploader or even per upload with a block: