Class: Adhoq::Storage::S3

Inherits:
FogStorage show all
Defined in:
lib/adhoq/storage/s3.rb

Instance Method Summary collapse

Methods inherited from FogStorage

#get, #get_raw, #store

Constructor Details

#initialize(bucket, s3_options = {}) ⇒ S3

Returns a new instance of S3.



6
7
8
9
10
11
# 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

Instance Method Details

#direct_download?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/adhoq/storage/s3.rb', line 13

def direct_download?
  @direct_download
end

#get_url(report) ⇒ Object



21
22
23
24
25
26
# 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

#identifierObject



17
18
19
# File 'lib/adhoq/storage/s3.rb', line 17

def identifier
  "s3://#{@bucket}"
end