aws-sdk-ruby icon indicating copy to clipboard operation
aws-sdk-ruby copied to clipboard

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

Open casret opened this issue 9 months ago • 3 comments

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

  • [ ] I may be able to implement this feature request
  • [ ] This feature might incur a breaking change

SDK version used

1.132.1

Environment details (OS name and version, etc.)

Ubuntu

casret avatar Sep 29 '23 17:09 casret

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

jterapin avatar Sep 29 '23 21:09 jterapin

This is an ongoing bug on S3's side. There's an internal tracking ticket with S3 - which was already created when this #2762 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.

jterapin avatar Oct 04 '23 20:10 jterapin

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

sj26 avatar Dec 18 '23 02:12 sj26