1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Handle multipart upload of empty files

This commit is contained in:
Frederick Cheung 2017-05-17 17:38:17 +01:00
parent 1577e12087
commit ed58cc3f47
2 changed files with 17 additions and 0 deletions

View file

@ -276,6 +276,11 @@ module Fog
part_tags << part_upload.headers["ETag"]
end
if part_tags.empty? #it is an error to have a multipart upload with no parts
part_upload = service.upload_part(directory.key, key, upload_id, 1, '', part_headers('', options))
part_tags << part_upload.headers["ETag"]
end
rescue
# Abort the upload & reraise
service.abort_multipart_upload(directory.key, key, upload_id) if upload_id

View file

@ -74,6 +74,18 @@ Shindo.tests("Storage[:aws] | file", ["aws"]) do
end
tests("multipart upload with empty file") do
pending if Fog.mocking?
@empty_file = Tempfile.new("fog-test-aws-s3-multipart-empty")
tests("#save(:multipart_chunk_size => 5242880)").succeeds do
@directory.files.create(:key => 'empty-multipart-upload', :body => @empty_file, :multipart_chunk_size => 5242880)
end
@empty_file.close
end
tests("multipart upload with customer encryption").returns(true) do
pending if Fog.mocking?