Search

Chapter 5. Downloading files from available Amazon S3 buckets using notebook cells

download PDF

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

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.