從鏈接,https://www.digitalocean.com/community/questions/how-to-upload-an-object-to-digital-ocean-spaces-using-python-boto3-library。它僅宣告將檔案上傳到空間。
我想將檔案夾上傳到空間。
import boto3
session = boto3.session.Session()
client = session.client('s3',
region_name='nyc3',
endpoint_url='https://nyc3.digitaloceanspaces.com',
aws_access_key_id='ACCESS_KEY',
aws_secret_access_key='SECRET_KEY')
client.upload_file('/path/to/file.ext', # Path to local file
'my-space', # Name of Space
'file.ext') # Name for remote file
這只上傳檔案。如何從這個程序上傳檔案夾或目錄?
uj5u.com熱心網友回復:
您的操作與 S3 相同,即迭代檔案夾中的檔案并在使用upload_file.
只有 AWS CLI 具有上傳檔案夾的高級功能。boto3只能上傳單個檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/357385.html
