我正在尝试在不使用凭证的情况下将大文件上传到 Amazon S3。我正在为 Octoprint 创建一个插件,由于它是公开的,我无法将任何类型的凭据放入代码中。目前我的上传代码如下所示:
import boto3
from botocore import UNSIGNED
from botocore.client import Config
s3 = boto3.client('s3', config=Config(signature_version=UNSIGNED))
# Create an S3 client
filename = 'file.txt'
bucket_name = 'BUCKET_HERE'
s3.upload_file(filename, bucket_name, filename)
但是,它给了我以下错误:
S3UploadFailedError: Failed to upload largefiletest.mp4 to BUCKETNAMEHERE/largefiletest.mp4: An error occurred (AccessDenied) when calling the CreateMultipartUpload operation: Anonymous users cannot initiate multipart uploads. Please authenticate.
有什么办法可以解决这个问题,或者对替代库有什么建议吗?任何事情都值得赞赏。