When using ruby to upload files to S3 and trying to use multipart upload, beware the following ArgumentError:
...param_validator.rb:32:in `validate!': unexpected value at params[:server_side_encryption] (ArgumentError) ... from /var/lib/jenkins/.gem/ruby/gems/aws-sdk-core-3.6.0/lib/seahorse/client/request.rb:70:in `send_request' from /var/lib/jenkins/.gem/ruby/gems/aws-sdk-s3-1.4.0/lib/aws-sdk-s3/client.rb:3980:in `list_parts' ...
The options passed to list_parts must not include “server_side_encryption”. I always forget to remove this parameter.
A good way that I have found to solve this issue is:
... input_opts = { bucket: bucket, key: key, server_side_encryption: "AES256", } if defined? mime_type input_opts = input_opts.merge({ content_type: mime_type, }) end ... input_opts.delete_if {|key,value| key.to_s.eql?("content_type") } input_opts.delete_if {|key,value| key.to_s.eql?("server_side_encryption") } input_opts = input_opts.merge({ :upload_id => mpu_create_response.upload_id, }) parts_resp = s3.list_parts(input_opts) ...
You can see here that I delete values that may have been added so that the final options hash will work with the list_parts call.
Leave a Reply