mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Merge pull request #283 from brettcave/3389-0-byte-multipart
Skip multipart if body size is less than chunk.
This commit is contained in:
commit
db9dc346f4
1 changed files with 9 additions and 2 deletions
|
@ -27,7 +27,11 @@ module Fog
|
|||
|
||||
# @note Chunk size to use for multipart uploads.
|
||||
# Use small chunk sizes to minimize memory. E.g. 5242880 = 5mb
|
||||
attr_accessor :multipart_chunk_size
|
||||
attr_reader :multipart_chunk_size
|
||||
def multipart_chunk_size=(mp_chunk_size)
|
||||
raise ArgumentError.new("minimum multipart_chunk_size is 5242880") if mp_chunk_size < 5242880
|
||||
@multipart_chunk_size = mp_chunk_size
|
||||
end
|
||||
|
||||
def acl
|
||||
requires :directory, :key
|
||||
|
@ -205,7 +209,10 @@ module Fog
|
|||
options['x-amz-storage-class'] = storage_class if storage_class
|
||||
options.merge!(encryption_headers)
|
||||
|
||||
if multipart_chunk_size && body.respond_to?(:read)
|
||||
# With a single PUT operation you can upload objects up to 5 GB in size. Automatically set MP for larger objects.
|
||||
multipart_chunk_size=5242880 if !multipart_chunk_size && Fog::Storage.get_body_size(body) > 5368709120
|
||||
|
||||
if multipart_chunk_size && Fog::Storage.get_body_size(body) >= multipart_chunk_size && body.respond_to?(:read)
|
||||
data = multipart_save(options)
|
||||
merge_attributes(data.body)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue