Chapter 6. Downloading files from your bucket
To download a file from your bucket to your workbench, use the download_file()
method.
Prerequisites
-
You have cloned the
odh-doc-examples
repository to your workbench. -
You have opened the
s3client_examples.ipynb
file in your workbench. - You have installed Boto3 and configured an S3 client.
Procedure
In the Jupyter notebook, locate the following instructions to download files from a bucket:
#Download file from bucket #Replace the following values with your own: #<bucket_name>: The name of the bucket. #<object_name>: The name of the file to download. Must include full path to the file on the bucket. #<file_name>: The name of the file when downloaded. s3_client.download_file('<bucket_name>','<object_name>','<file_name>')
#Download file from bucket #Replace the following values with your own: #<bucket_name>: The name of the bucket. #<object_name>: The name of the file to download. Must include full path to the file on the bucket. #<file_name>: The name of the file when downloaded. s3_client.download_file('<bucket_name>','<object_name>','<file_name>')
Copy to Clipboard Copied! Modify the code sample:
-
Replace
<bucket_name>
with the name of the bucket that the file is located in… Replace<object_name>
with the name of the file that you want to download. Replace
<file_name>
with the name and path that you want the file to be downloaded to, as shown in the example.s3_client.download_file('aqs086-image-registry', 'series35-image36-086.csv', '\tmp\series35-image36-086.csv_old')
s3_client.download_file('aqs086-image-registry', 'series35-image36-086.csv', '\tmp\series35-image36-086.csv_old')
Copy to Clipboard Copied!
-
Replace
- Run the code cell.
Verification
- The file that you downloaded appears in the path that you specified on your workbench.