2

I am generating presigned post url using this

 response = s3.generate_presigned_post(
        'uploads',
         'myurl/24a5c08c2e64/${filename}',
        Fields={
            'x-amz-meta-id': id,
        },
        Conditions=[
                ["starts-with", "$key", "myurl/"],
                {'x-amz-meta-id': id},
            ],
        ExpiresIn=(3*60*60),
    )

but I am unable to upload file because I am not getting x-amz-security-token in response . so what could be reason ? please help

that's how I am uploading using Postman and getting Access Denied error enter image description here

zampa
  • 63
  • 1
  • 10
  • "upload file" - how exactly are you uploading the file. Please describe all the commands and procedure in detail. – Marcin Mar 07 '22 at 23:44
  • What do you mean by "not getting x-amz-security-token in response"? – John Rotenstein Mar 07 '22 at 23:59
  • I think this is because you used IAM User credentials to sign the URL. If you had used STS credentials, you would have `x-amz-security-token` in the returned URL. Either way, it's there in the URL if needed and absent if not needed. How is your upload attempt actually failing? – jarmod Mar 08 '22 at 01:38
  • @jarmod on uploading I am getting Access Denied error . when I upload without `x-amz-security-token` as not getting in response – zampa Mar 08 '22 at 06:21
  • Ignore `x-amz-security-token`; it's a red herring. Use whatever URL the generate_presigned_post() method returns to you. It looks like you're using PUT, but you asked for a pre-signed POST URL. If that's not the issue, then you need to make sure that the credentials used to sign this URL actually have permission to upload to the S3 bucket/key that you're trying to upload to, and that your upload meets the conditions specified in the POST policy. Also read [this answer](https://stackoverflow.com/questions/35789520/how-do-i-put-object-to-amazon-s3-using-presigned-url) as it may be helpful. – jarmod Mar 08 '22 at 13:05

0 Answers0