Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
2 consiquenced presign post urls to S3 with boto3

I`m trying to generate 2 consequence pressing post urls for posting to S3 using boto3. This urls I return to user to post 2 semantically connected files that have different format.

full_ecs_xsd_key = 'txn/jackalope/edispec/TPD/local/opikovets/my_test_file_3'

fields = {
    "x-amz-meta-identity-id": user_id,
    "x-amz-server-side-encryption": "AES256"
}
conditions = [
    {"x-amz-meta-identity-id": user_id},
    {"x-amz-server-side-encryption": "AES256"}
]

xsd_key = full_ecs_xsd_key + '.xsd'
pre_signed_xsd_post_url = copy.deepcopy(s3_client.generate_presigned_post(
    bucket_name, xsd_key,
    Fields=fields,
    Conditions=conditions
))

ecs_key = full_ecs_xsd_key + '.ecs'
pre_signed_ecs_post_url = copy.deepcopy(s3_client.generate_presigned_post(
    bucket_name, ecs_key,
    Fields=fields,
    Conditions=conditions
))

as a result, I get 2 urls which seems to be working, but I`m not able to post data to the second url (pre_signed_ecs_post_url). Getting an error

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>AccessDenied</Code>
    <Message>Invalid according to Policy: Policy Condition failed: ["eq", "$key", "txn/jackalope/edispec/TPD/local/opikovets/my_test_file_3.xsd"]</Message>
    <RequestId>1343F7E406E82C1A</RequestId>
    <HostId>wm0U14OouoMkbm0bWIqkYDtP7fgR2A+0Q/Mvhvo9sJ7paaXDiMWfqnjCMR4mc5euPcXCyP3u2/w=</HostId>
</Error>

What is confusing here is that key, displayed in the error is actually a key for the first url, not the second one. So, I think that when I call generate_presigned_post for the first time it creates an instance of a class that is also used for creating second url...

But that`s only a guess, and I have no idea how to solve this particular problem

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Per @Michael-sqlbot comments, fields and conditions are changing during the generate_presigned_post() execution, so I`ve changed the call to:

ecs_key = full_ecs_xsd_key + '.ecs'
pre_signed_ecs_post_url = s3_client.generate_presigned_post(
    bucket_name, ecs_key,
    Fields=copy.deepcopy(fields),
    Conditions=copy.deepcopy(conditions)
)

xsd_key = full_ecs_xsd_key + '.xsd'
pre_signed_xsd_post_url = s3_client.generate_presigned_post(
    bucket_name, xsd_key,
    Fields=copy.deepcopy(fields),
    Conditions=copy.deepcopy(conditions)
)

and everything worked just fine

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!