class PaperclipArchiveProcessor::Processor::S3
Public Class Methods
extract(attachment, extractor)
click to toggle source
# File lib/paperclip_archive_processor/processor.rb, line 33 def self.extract(attachment, extractor) extract_path = Dir.mktmpdir s3_path_prefix = File.dirname(attachment.path) bucket_name = attachment.instance_variable_get(:@options)[:bucket] options = options_for(attachment) extractor.extract(attachment.to_file.path, extract_path).each do |name| file = File.join(extract_path, name) write(File.join(s3_path_prefix, name), File.new(file), bucket_name, options) if File.file?(file) end end
options_for(attachment)
click to toggle source
# File lib/paperclip_archive_processor/processor.rb, line 45 def self.options_for(attachment) { :content_type => attachment.content_type, :access => attachment.instance_variable_get(:@s3_permissions) }.merge(attachment.instance_variable_get(:@s3_headers)) end
write(path, file, bucket_name, options)
click to toggle source
# File lib/paperclip_archive_processor/processor.rb, line 51 def self.write(path, file, bucket_name, options) begin AWS::S3::S3Object.store(path, file, bucket_name, options) rescue AWS::S3::ResponseError raise end end