Last active
August 29, 2015 13:57
-
-
Save samwgoldman/9610193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
access_key_id = ENV.fetch("APP_S3_ACCESS_KEY_ID") | |
secret_access_key = ENV.fetch("APP_S3_SECRET_ACCESS_KEY") | |
bucket_name = ENV.fetch("APP_S3_BUCKET") | |
s3 = AWS::S3.new(access_key_id: access_key_id, secret_access_key: secret_access_key) | |
bucket = s3.buckets[bucket_name] | |
object = bucket.objects["whatever/you/want"] | |
presign = AWS::S3::PresignV4.new(object) | |
presign.presign(:put, expires: 15.minutes.from_now.to_i) | |
# => #<URI::HTTP:0x007fcfcd97e1a0 URL:***stuff***> | |
# Note: When I did this, I got back a URL like http://host:443/... but I had to change it to | |
# https://host/ for the signed property to match. Seems like a bug with aws-sdk. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment