Skip to content

Commit

Permalink
For s3 driver, configurable expires_in for signed_urls
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed May 17, 2018
1 parent a1e7939 commit 0e01d65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/browse_everything/driver/s3.rb
Expand Up @@ -6,7 +6,7 @@
module BrowseEverything
module Driver
class S3 < Base
DEFAULTS = { response_type: :signed_url }.freeze
DEFAULTS = { response_type: :signed_url, expires_in: 14400 }.freeze
RESPONSE_TYPES = %i[signed_url public_url s3_uri].freeze
CONFIG_KEYS = %i[bucket].freeze

Expand Down Expand Up @@ -62,7 +62,7 @@ def details(path)
def link_for(path)
obj = bucket.object(full_path(path))
case config[:response_type].to_sym
when :signed_url then obj.presigned_url(:get, expires_in: 14400)
when :signed_url then obj.presigned_url(:get, expires_in: config[:expires_in])
when :public_url then obj.public_url
when :s3_uri then "s3://#{obj.bucket_name}/#{obj.key}"
end
Expand Down
Expand Up @@ -14,6 +14,7 @@
# s3:
# bucket: YOUR_AWS_S3_BUCKET
# response_type: :signed_url # set to :public_url for public urls or :s3_uri for an s3://BUCKET/KEY uri
# expires_in: 14400 # for signed_url response_type, number of seconds url will be valid for.
# app_key: YOUR_AWS_S3_KEY # :app_key, :app_secret, and :region can be specified
# app_secret: YOUR_AWS_S3_SECRET # explicitly here, or left out to use system-configured
# region: YOUR_AWS_S3_REGION # defaults.
Expand Down

0 comments on commit 0e01d65

Please sign in to comment.