Class: AWS::S3::S3Object
Class Method Summary collapse
- .original_store ⇒ Object
- .store(key, data, bucket = nil, options = {}) ⇒ Object
- .store_directory(directory, bucket, options = {}) ⇒ Object
- .store_folder(key, bucket = nil, options = {}) ⇒ Object
- .store_folders(key, bucket = nil, options = {}) ⇒ Object
- .streamed_store(key, filepath, bucket = nil, options = {}) ⇒ Object
Class Method Details
.original_store ⇒ Object
9 |
# File 'lib/s3/s3_object_store_folders.rb', line 9 alias :original_store :store |
.store(key, data, bucket = nil, options = {}) ⇒ Object
10 11 12 13 |
# File 'lib/s3/s3_object_store_folders.rb', line 10 def store(key, data, bucket = nil, = {}) store_folders(key, bucket, ) if [:use_virtual_directories] original_store(key, data, bucket, ) end |
.store_directory(directory, bucket, options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/s3/s3_object_store_folders.rb', line 20 def store_directory(directory, bucket, = {}) Dir[File.join(directory, "*")].each do |file| streamed_store("#{File.basename(File.dirname(file))}/#{File.basename(file)}", file, bucket, .update(:use_virtual_directories => true)) end end |
.store_folder(key, bucket = nil, options = {}) ⇒ Object
38 39 40 |
# File 'lib/s3/s3_object_store_folders.rb', line 38 def store_folder(key, bucket = nil, = {}) original_store(key + "_$folder$", "", bucket, ) # store the magic entry that emulates a folder end |
.store_folders(key, bucket = nil, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/s3/s3_object_store_folders.rb', line 26 def store_folders(key, bucket = nil, = {}) folders = key.split("/") folders.slice!(0) folders.pop current_folder = "/" folders.each {|folder| current_folder += folder store_folder(current_folder, bucket, ) current_folder += "/" } end |
.streamed_store(key, filepath, bucket = nil, options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/s3/s3_object_store_folders.rb', line 15 def streamed_store(key, filepath, bucket = nil, = {}) store_folders(key, bucket, ) if [:use_virtual_directories] store(key,File.open(filepath), bucket) end |