class Adhoq::Storage::S3
Public Class Methods
Source
# File lib/adhoq/storage/s3.rb, line 6 def initialize(bucket, s3_options = {}) @bucket = bucket @direct_download = s3_options.delete(:direct_download) @direct_download_options = s3_options.delete(:direct_download_options) || default_direct_download_options @s3 = Fog::Storage.new({provider: 'AWS'}.merge(s3_options)) end
Public Instance Methods
Source
# File lib/adhoq/storage/s3.rb, line 13 def direct_download? @direct_download end
Source
# File lib/adhoq/storage/s3.rb, line 21 def get_url(report) get_raw(report.identifier).url( 1.minutes.from_now.to_i, @direct_download_options.call(report) ) end
Private Instance Methods
Source
# File lib/adhoq/storage/s3.rb, line 36 def default_direct_download_options proc do |report| { query: { 'response-content-disposition' => "attachment; filename*=UTF-8''#{URI.encode_www_form_component(report.name)}", 'response-content-type' => report.mime_type, } } end end
Source
# File lib/adhoq/storage/s3.rb, line 30 def directory return @directory if @directory @directory = @s3.directories.get(@bucket) || @s3.directories.create(key: @bucket, public: false) end