1
0
Fork 0
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:
Wesley Beary 2016-08-01 08:58:13 -05:00 committed by GitHub
commit db9dc346f4

View file

@ -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