上载大量文件时出现SignatureDesNotMatch错误

2024-04-25 18:26:10 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试用python/boto3将500个文件上载到S3兼容的对象存储时出错。你知道吗

我编写了一个cronjob来检测特定目录中的文件,并使用boto3库将这些文件上传到S3 bucket中。能够上传400多个文件,它退出时出现以下错误。我不认为这是一个凭据问题,因为它是上传400多个文件在此错误之前。你知道吗

boto3.exceptions.S3UploadFailedError: Failed to upload 00000432_1081801000_06042019_07042019.pdf to as003a/36437128: An error occurred (SignatureDoesNotMatch) when calling the PutObject operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. For more information, see REST Authentication and SOAP Authentication for details.

 # inside a loop of the list of files
 if os.path.exists(filename):
     totalUploadSize += os.stat(filename).st_size
     totalUploadCount += 1
     obj = s3.Object('as003a', s3id )
     obj.upload_file(filename, ExtraArgs={"Metadata": billMetadata})
     os.remove(filename)

我面临这个问题,甚至在文件430左右,我需要有它的工作,为10000在一批与10批一天。你知道吗


Tags: and文件ofthetoobjauthentications3