aws / aws-sdk-ruby

The official AWS SDK for Ruby.
https://aws.amazon.com/sdk-for-ruby/
Apache License 2.0
3.56k stars 1.22k forks source link

Aws::S3::PresignedPost does not support tagging field #2919

Open casret opened 1 year ago

casret commented 1 year ago

Describe the feature

The PresignedPost does not seem to support the 'tagging' form field.

Use Case

I would like to require certain tags for objects that are uploaded in s3.

Proposed Solution

Ideally you would be able to pass a tagging: parameter what would take the same format as put_object_tagging from the s3 client.

Other Information

No response

Acknowledgements

SDK version used

1.132.1

Environment details (OS name and version, etc.)

Ubuntu

jterapin commented 1 year ago

Thank you for the ticket. We will investigate and let you know.

jterapin commented 12 months ago

This is an ongoing bug on S3's side. There's an internal tracking ticket with S3 - which was already created when this aws/aws-sdk#782 came in. Until this S3 bug is resolved, we are blocked on implementing this feature since PresignedPost uses presigned_url.

In the meantime, I will follow up with S3 on the status.

sj26 commented 9 months ago

Also keen to see this fixed, so we can use it at Buildkite :pray:

Something like this sorta works to make the client side bit work, but it fails with a "400 Bad Request" from S3:

require "aws-sdk-s3"

# Aws' sdk doesn't natively support this in presigned posts, but is supported
# by the S3 API:
#
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html
#
Aws::S3::PresignedPost.class_eval do
  # @!method tagging(hash)
  #   Tagging hash to store with the uploaded object. Turns into a header:
  #
  #     x-amz-tagging: Key=Value1&Key2=Value2&...
  #
  #   The header will be hoisted into params for presigned forms.
  #
  #   @param [Hash<String,String>] hash
  #   @return [self]
  define_field(:tagging) do |hash|
    with("x-amz-tagging", hash.to_query)
    self
  end
end