以下是一个使用AWS SDK for Python (Boto3)将文件上传到S3的示例代码:
import boto3
s3 = boto3.client("s3", aws_access_key_id="YOUR_AWS_ACCESS_KEY", aws_secret_access_key="YOUR_AWS_SECRET_KEY")
file_path = "path_to_file/filename.extension"
bucket_name = "your_bucket_name" s3_file_name = "s3_filename.extension"
with open(file_path, "rb") as f: s3.upload_fileobj(f, bucket_name, s3_file_name)
print("文件上传成功")