Home > Blockchain >  S3 URL - Download with python
S3 URL - Download with python

Time:05-30

I need to download a file from this URL https://desafio-rkd.s3.amazonaws.com/disney_plus_titles.csv with Python, try to do it with "" require.get '", but it returns me denied access. I understand that I have to authenticate. I have the key and the secret key, but I do not know how to do it. Help me please?

CodePudding user response:

The preferred way would be to use the boto3 library for Amazon S3. It has a download_file() command, for which you would use:

import boto3

s3_client = boto3.client('s3')
s3_client.download_file('desafio-rkd', 'disney_plus_titles.csv', 'disney_plus_titles.csv')

The parameters are: Bucket, Key, local filename to use when saving the file

Also, you will need to provide an Access Key and Secret Key. The preferred way to do this is to store them in a credentials file. This can be done by using the AWS Command-Line Interface (CLI) aws configure command.

See: Credentials — Boto3 documentation

  • Related