Sha256: 6dae1aec96c565ae4c8b0c9d2d8d23118eb0a83c2707de1fe8bbb04512f118c5
Contents?: true
Size: 1.34 KB
Versions: 6
Compression:
Stored size: 1.34 KB
Contents
require 'right_aws' module TranscodingMachine module Server class S3Storage def initialize @s3 = RightAws::S3.new(nil, nil, :server => 's3.amazonaws.com', :port => 80, :protocol => 'http') end def get_file(key_name, destination_file_path, options) file = File.new(destination_file_path, File::CREAT|File::RDWR) rhdr = @s3.interface.get(options[:bucket], key_name) do |chunk| file.write(chunk) end file.close end def put_file(source_file_path, destination_file_name, media_format, options) destination_key = RightAws::S3::Key.create(@s3.bucket(options[:bucket]), destination_file_name) s3_headers = { 'Content-Type' => media_format.mime_type, 'Content-Disposition' => "attachment; filename=#{File.basename(destination_file_name)}" } destination_key.put(File.new(source_file_path), 'public-read', s3_headers) FileUtils.rm(source_file_path) end def put_thumbnail_file(thumbnail_file, source_file_key_name, options) destination_key = RightAws::S3::Key.create(@s3.bucket(options[:bucket]), "#{source_file_key_name}.thumb.jpg") destination_key.put(thumbnail_file, 'public-read', 'Content-Type' => 'image/jpg') FileUtils.rm(thumbnail_file.path) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems