Skip to content

Commit

Permalink
Merge pull request fog#1137 from fcheung/idempotent_s3
Browse files Browse the repository at this point in the history
[AWS|Storage] Mark upload_part as idempotent s3
  • Loading branch information
fcheung committed Sep 10, 2012
2 parents 20e0f49 + 2bf37ef commit eb700e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fog/aws/models/storage/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def multipart_save(options)
# TODO: Support large chunk sizes without reading the chunk into memory
body.rewind if body.respond_to?(:rewind)
while (chunk = body.read(multipart_chunk_size)) do
part_upload = connection.upload_part(directory.key, key, upload_id, part_tags.size + 1, chunk )
md5 = Base64.encode64(Digest::MD5.digest(chunk)).strip
part_upload = connection.upload_part(directory.key, key, upload_id, part_tags.size + 1, chunk, 'Content-MD5' => md5 )
part_tags << part_upload.headers["ETag"]
end

Expand Down
1 change: 1 addition & 0 deletions lib/fog/aws/requests/storage/upload_part.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def upload_part(bucket_name, object_name, upload_id, part_number, data, options
request({
:body => data[:body],
:expects => 200,
:idempotent => true,
:headers => headers,
:host => "#{bucket_name}.#{@host}",
:method => 'PUT',
Expand Down

0 comments on commit eb700e6

Please sign in to comment.