module S3Proxy
Constants
- VERSION
Public Instance Methods
proxy_s3_file(bucket, key)
click to toggle source
# File lib/s3proxy.rb, line 6 def proxy_s3_file(bucket, key) cached_file = cache_location(bucket, key) options = { bucket: bucket, key: key, } options[:if_modified_since] = File.mtime(cached_file) if File.exists?(cached_file) begin s3object = s3.get_object(options, target: cached_file) rescue Aws::S3::Errors::NotModified options.delete(:if_modified_since) s3object = s3.head_object(options) end File.new cached_file end
Private Instance Methods
cache_location(bucket, key)
click to toggle source
# File lib/s3proxy.rb, line 25 def cache_location(bucket, key) hash = Digest::MD5.hexdigest "#{bucket}/#{key}" path = "#{Dir.tmpdir}/s3proxy-#{Process.pid}" Dir.mkdir(path, 0700) unless File.exists?(path) "#{path}/#{hash}" end
s3()
click to toggle source
# File lib/s3proxy.rb, line 33 def s3 @s3 ||= Aws::S3::Client.new end