Chapter 5. Downloading files from available Amazon S3 buckets using notebook cells
You can download a file to your notebook server using the download_file
method.
Prerequisites
- Configure an Amazon S3 client in a previous cell in the notebook. See Creating an Amazon S3 client using notebook cells for more information.
Procedure
Define the following details in a notebook cell:
The bucket that the file is in. Replace
<name_of_the_bucket>
with your own value.bucket_name = '<name_of_the_bucket>'
The name of the file to download. Replace
<name_of_the_file_to_download>
with your own value.file_name = '<name_of_the_file_to_download>' # Full path from the bucket
The name that you want the file to have after it is downloaded. This can be a full path, a relative path, or just a new file name. Replace
<name_of_the_file_when_downloaded>
with your own value.new_file_name = '<name_of_the_file_when_downloaded>'
Download the file, specifying the previous variables as arguments.
s3_client.download_file(bucket_name, file_name, new_file_name)
NoteIf you want to retrieve a file as an object that you can then stream as a standard file using the read() method, refer to the Amazon Web Services get object command reference.