我可以使用 C# 将 S3 存储桶中的对象从一个目录移动到另一个目录,但无法复制该对象的所有当前权限。
例如,我当前的对象具有公共访问权限,但在将其移动到另一个目录后,它失去了公共读取权限。
这是我用来移动对象的代码:
public void MoveFile(string sourceBucket, string destinationFolder, string file) {
AmazonS3Client s3Client = new AmazonS3Client(ConfigurationHelper.AmazonS3AccessKey, ConfigurationHelper.AmazonS3SecretAccessKey, Amazon.RegionEndpoint.USEast1);
S3FileInfo currentObject = new S3FileInfo(s3Client, sourceBucket, file);
currentObject.MoveTo(sourceBucket + "/" + destinationFolder, file);
}
这是将文件移动到另一个目录后的输出:
它失去了公开的“读取”权限。