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

287
Vistas
Access denied error when curl'ing S3 object from pre-signed url

This is the script which I wrote for downloading object from S3 via a pre-signed url:

import boto3
import os


AWS_ACCESS_KEY_ID = '<>'
AWS_SECRET_ACCESS_KEY = '<>'
region = '<>'

session = boto3.Session(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, region_name = region)
s3 = session.client('s3')
url = s3.generate_presigned_url('get_object', Params = {'Bucket': '<>', 'Key': '<>.json'}, ExpiresIn = 100)

print url

os.system('curl ' + url)

From this, I am able to get the url, but the os.system command is giving me the following error:

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>...</RequestId><HostId>...</HostId></Error>

But, when I directly try the url in my browser, it is downloading the file.

So, what did I do wrong here? How do I download the file via the Python script?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Surround the url with quotes (") when making the curl request.

os.system('curl "'+ url + '"')

To save it in a file, use

os.system('curl -o /tmp/file.txt "'+ url + '"')

Or, Use the requests module to make the GET

import requests
response = requests.get(url)
about 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