diff --git a/lib/fog/storage/aws.rb b/lib/fog/storage/aws.rb index 8ca6c5840..13aae31f0 100644 --- a/lib/fog/storage/aws.rb +++ b/lib/fog/storage/aws.rb @@ -64,16 +64,14 @@ module Fog :headers => {} } - if data.is_a?(String) - metadata[:body] = data - metadata[:headers]['Content-Length'] = metadata[:body].size - else + metadata[:body] = data + metadata[:headers]['Content-Length'] = data.size + + if data.respond_to?(:path) filename = ::File.basename(data.path) unless (mime_types = MIME::Types.of(filename)).empty? metadata[:headers]['Content-Type'] = mime_types.first.content_type end - metadata[:body] = data - metadata[:headers]['Content-Length'] = ::File.size(data.path) end # metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip metadata diff --git a/lib/fog/storage/models/aws/file.rb b/lib/fog/storage/models/aws/file.rb index 4fd984993..aadaeae39 100644 --- a/lib/fog/storage/models/aws/file.rb +++ b/lib/fog/storage/models/aws/file.rb @@ -118,11 +118,6 @@ module Fog data = connection.put_object(directory.key, key, body, options) merge_attributes(data.headers) - if body.is_a?(String) - self.content_length = body.size - else - self.content_length = ::File.size(body.path) - end true end