我无法将我的文件上传到我刚刚在S3中创建的bucket中。你知道吗
但是,另一个文件,我上传到不同的bucket正常运行没有错误。 所以,我相信,问题在于桶本身而不是代码。你知道吗
现在,我已经向每个人授予了权限,就像这样 而且,也没有什么政策。你知道吗
这是我的cors桶:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
这是mycode的快照
class Handler:
...
def s3save(self, local_path, remote_path, metadata=None, savebucket=None):
chunk_size = Handler.CHUNK_SIZE
headers = self.default_s3_headers if metadata is None else metadata
mpu = savebucket.initiate_multipart_upload(
remote_path,
headers=headers,
policy="public-read"
)
# code copy-ed from someone from stackoverflow
source_size = os.stat(local_path).st_size
chunk_count = int(math.ceil(source_size / float(chunk_size)))
print(local_path, remote_path, savebucket)
for i in xrange(chunk_count):
offset = chunk_size * i
bytelength = min(chunk_size, source_size - offset)
with FileChunkIO(local_path, "r", offset=offset, bytes=bytelength) as fp:
mpu.upload_part_from_file(fp, part_num=i + 1)
mpu.complete_upload()
但不管怎样,我还是犯了一个错误:
error: [Errno 104] Connection reset by peer
目前没有回答
相关问题 更多 >
编程相关推荐