Sha256: f8a1906f79bf716b7c8670fa1907d56998598e74e9ae6ff18b7fd620f1a87245
Contents?: true
Size: 1.23 KB
Versions: 5
Compression:
Stored size: 1.23 KB
Contents
require 'fog' module Adhoq module Storage class S3 < FogStorage 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 def direct_download? @direct_download end def identifier "s3://#{@bucket}" end def get_url(report) get_raw(report.identifier).url( 1.minutes.from_now.to_i, @direct_download_options.call(report) ) end private def directory return @directory if @directory @directory = @s3.directories.get(@bucket) || @s3.directories.create(key: @bucket, public: false) end 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
adhoq-0.1.2 | lib/adhoq/storage/s3.rb |
adhoq-0.1.1 | lib/adhoq/storage/s3.rb |
adhoq-0.1.0 | lib/adhoq/storage/s3.rb |
adhoq-0.0.7 | lib/adhoq/storage/s3.rb |
adhoq-0.0.6 | lib/adhoq/storage/s3.rb |