Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda