-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature: ability to generate virtually-hosted/cnamed urls for a given bucket #786
Comments
Thanks for posting the feature request. I'm out traveling for the week, but lets continue the conversation early next week. |
@trevorrowe Have you been able to look into this? We badly need support for presigned urls using CNAMEd buckets. Unlike @jbr, we host the files outside us-standard so +1 to a solution that somehow takes that into account before we close this door and make it difficult to add this functionality in the future. If there's any way I can help move it forward, please let me know. |
@bilus I was previously looking at this. I have a local proof of concept branch which lacks tests. I got to the point where I needed a live bucket in S3 with a cname and I lacked one at the time. I need to circle back on this, but haven't had the opportunity too. |
Actually, I've been able to generate the urls using the code similar to this: bucket_name = "some-bucket.example.com"
s3 = Aws::S3::Client.new(endpoint: "http://example.com", region: "eu-central-1")
bucket = Aws::S3::Bucket.new("some-bucket", client: s3)
object = bucket.object("some-key")
object.presigned_url(:get, expires_in: 24 * 3600, secure: false) This probably gives a better idea of what goes where (and should probably work but it's untested): def generate_presigned_url(region, domain, bucket_basename, key, expire_after)
bucket_name = "#{bucket_basename}.#{domain}"
s3 = Aws::S3::Client.new(endpoint: "http://#{domain}", region: region)
bucket = Aws::S3::Bucket.new(bucket_basename, client: s3)
object = bucket.object(key)
object.presigned_url(:get, expires_in: expire_after, secure: false)
end As this based on stepping through the code with a debugger and not docs, I'm leaving stuff that can probably be omitted (e.g. region). The |
I have a us standard bucket with a bucket name that is also a cnamed fqdn like
storage.mysite.com
and would like any generated urls to use that cname / virtual host. By generated urls, I mean any url that might be public-facing, not necessarily urls that the gem uses internally to speak to s3. In my use case, this would includeAws::S3::Object#public_url
andAws::S3::Object#presigned_url
, but there may be more methods like this. It would be ideal to set this on creation / access of the bucket, like:It might be useful to someone if that could also be overridden per object method, so
BUCKET.object('not-cnamed').public_url(virtual_host: false)
would revert to default behavior, or sowould result in something like
http://storage.mysite.com/cnamed
This could also raise a useful exception if the bucket isn't us-standard and the user is trying to set
virtual_host: true
I understand that this would be mutually exclusive with
secure: true
and would expect the gem to raise if I tried to specify both of them.Thank you!
The text was updated successfully, but these errors were encountered: