Chapter 6. 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

Procedure

  1. Define the following details in a notebook cell:

    1. The bucket that the file is in. Replace <name_of_the_bucket> with your own value.

      bucket_name = '<name_of_the_bucket>'
    2. 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
    3. 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>'
  2. Download the file, specifying the previous variables as arguments.

    s3_client.download_file(bucket_name, file_name, new_file_name)
    Note

    If 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 Sev Services get object command reference.