Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

295
Visualizações
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?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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)
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda