第 6 章 从存储桶下载文件
要从存储桶下载文件到工作台,请使用 download_file () 方法。
先决条件
-
您已将
odh-doc-examples存储库克隆到工作台中。 -
您已在工作台中打开
s3client_examples.ipynb文件。 - 已安装 Boto3 并配置了 S3 客户端。
流程
在笔记本中,找到以下从存储桶下载文件的说明:
#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>')修改代码示例:
-
将
<bucket_name> 替换为文件位于… 中的存储桶名称,将 <object_name> 替换为您要下载的文件的名称。 将 <
file_name> 替换为您要下载该文件的名称和路径,如示例所示。s3_client.download_file('aqs086-image-registry', 'series35-image36-086.csv', '\tmp\series35-image36-086.csv_old')
-
将
- 运行代码单元。
验证
- 您下载的文件会出现在您在工作台中指定的路径中。