首页 > 解决方案 > How to use AWS CopyObjectRequest when Source and Destination buckets have different AccessKey & Secret

问题描述

I have 2 different buckets with different AccessKeys and Secrets. So I created 2 different s3Client objects to interact with them.

I am trying to figure out how to use CopyObjectRequest to copy a file from Bucket A (source) to Bucket B (destination).

SourceBucket property of this CopyObjectRequest class is a simple string name of the bucket.

标签: c#amazon-s3.net-core

解决方案


CopyObjectRequest除非您拥有一组具有适当权限的凭据来在两个存储桶上执行所有需要的操作,否则无法使用 a 。

这使用了服务 API 的PUT Object Copy操作,即发送到目标存储桶的请求,指示目标存储桶直接从源存储桶中获取对象,并使用对目标存储桶签署请求的用户的身份并存储副本。 . 避免需要下载和重新上传对象。在此模型中不支持第二组凭据,因为不会发生与源存储桶的直接交互——与源存储桶的交互发生在 S3 内部,数据传输也是如此,甚至跨区域也是如此。

使用两组凭据的唯一选项是下载,然后上传。


推荐阅读