lib/aws/s3/s3_object.rb in aws-sdk-1.8.1.2 vs lib/aws/s3/s3_object.rb in aws-sdk-1.8.1.3
- old
+ new
@@ -558,10 +558,13 @@
# what decoding mechanisms must be applied to obtain the
# media-type referenced by the +Content-Type+ header field.
# See
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
#
+ # @option options [String] :content_md5
+ # The base64 encoded content md5 of the data.
+ #
# @option options :content_type A standard MIME type
# describing the format of the object data.
#
# @option options [Symbol] :server_side_encryption (nil) If this
# option is set, the object will be stored using server side
@@ -1047,11 +1050,12 @@
options[:key] = key
if should_decrypt?(options)
get_encrypted_object(options, &read_block)
else
- get_object(options, &read_block)
+ resp_data = get_object(options, &read_block)
+ block_given? ? resp_data : resp_data[:data]
end
end
# @private
@@ -1260,23 +1264,24 @@
options[:encryption_key] or config.s3_encryption_key
end
# A small wrapper around client#get_object
def get_object options, &read_block
- client.get_object(options, &read_block).data[:data]
+ client.get_object(options, &read_block).data
end
# A wrapper around get_object that decrypts
def get_encrypted_object options, &read_block
decryption_cipher(options) do |cipher|
if block_given?
- get_object(options) do |chunk|
+ resp = get_object(options) do |chunk|
yield(cipher.update(chunk))
end
yield(cipher.final)
+ resp
else
- cipher.update(get_object(options)) + cipher.final
+ cipher.update(get_object(options)[:data]) + cipher.final
end
end
end
# @return [Boolean] Returns +true+ if the :data option is large or
@@ -1508,11 +1513,11 @@
location = options[:encryption_materials_location] ||
config.s3_encryption_materials_location
cipher =
- decryption_materials(location) do |envelope_key, envelope_iv|
+ decryption_materials(location, options) do |envelope_key, envelope_iv|
envelope_key, envelope_iv =
decode_envelope_key(envelope_key, envelope_iv, encryption_key)
get_aes_cipher(:decrypt, :CBC, envelope_key, envelope_iv)
end
@@ -1537,14 +1542,14 @@
end
# @yield [String, String, String] Yields encryption materials for
# decryption
- def decryption_materials location, &block
+ def decryption_materials location, options = {}, &block
materials = case location
- when :metadata then get_metadata_materials
+ when :metadata then get_metadata_materials(options)
when :instruction_file then get_inst_file_materials
else
msg = "invalid :encryption_materials_location option, expected "
msg << ":metadata or :instruction_file, got: #{location.inspect}"
raise ArgumentError, msg
@@ -1560,11 +1565,13 @@
end
# @return [String, String, String] Returns the data key, envelope_iv, and the
# material description for decryption from the metadata.
- def get_metadata_materials
- metadata.to_h.values_at(*%w(x-amz-key x-amz-iv))
+ def get_metadata_materials(options)
+ opts = {}
+ opts[:version_id] = options[:version_id] if options[:version_id]
+ metadata(opts).to_h.values_at(*%w(x-amz-key x-amz-iv))
end
# @return [String, String, String] Returns the data key, envelope_iv, and the
# material description for decryption from the instruction file.
def get_inst_file_materials