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

285
Views
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 answers
Answer question

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 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!