Class: PaperclipArchiveProcessor::Processor::S3
- Inherits:
-
Object
- Object
- PaperclipArchiveProcessor::Processor::S3
- Defined in:
- lib/paperclip_archive_processor/processor.rb
Class Method Summary collapse
- .extract(attachment, extractor) ⇒ Object
- .options_for(attachment) ⇒ Object
- .write(path, file, bucket_name, options) ⇒ Object
Class Method Details
.extract(attachment, extractor) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/paperclip_archive_processor/processor.rb', line 33 def self.extract(, extractor) extract_path = Dir.mktmpdir s3_path_prefix = File.dirname(.path) bucket_name = .instance_variable_get(:@options)[:bucket] = () extractor.extract(.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, ) if File.file?(file) end end |
.options_for(attachment) ⇒ Object
45 46 47 48 49 |
# File 'lib/paperclip_archive_processor/processor.rb', line 45 def self.() { :content_type => .content_type, :access => .instance_variable_get(:@s3_permissions) }.merge(.instance_variable_get(:@s3_headers)) end |
.write(path, file, bucket_name, options) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/paperclip_archive_processor/processor.rb', line 51 def self.write(path, file, bucket_name, ) begin AWS::S3::S3Object.store(path, file, bucket_name, ) rescue AWS::S3::ResponseError raise end end |