第 6 章 从存储桶下载文件


要从存储桶下载文件到工作台,请使用 download_file () 方法。

先决条件

  • 您已将 odh-doc-examples 存储库克隆到工作台中。
  • 您已在工作台中打开 s3client_examples.ipynb 文件。
  • 已安装 Boto3 并配置了 S3 客户端。

流程

  1. 在 Jupyter 笔记本中,找到以下从存储桶下载文件的说明:

    #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 Toggle word wrap
  2. 修改代码示例:

    1. <bucket_name > 替换为文件位于…​ 中的存储桶名称,将 &lt ;object_name > 替换为您要下载的文件的名称。
    2. 将 < file_name > 替换为您要下载该文件的名称和路径,如示例所示。

      s3_client.download_file('aqs086-image-registry',
                              'series35-image36-086.csv',
                              '\tmp\series35-image36-086.csv_old')
      Copy to Clipboard Toggle word wrap
  3. 运行代码单元。

验证

  • 您下载的文件会显示在您在工作台中指定的路径中。
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat