Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net AWS S3中复制对象的访问被拒绝_.net_Amazon Web Services_Amazon S3 - Fatal编程技术网

.net AWS S3中复制对象的访问被拒绝

.net AWS S3中复制对象的访问被拒绝,.net,amazon-web-services,amazon-s3,.net,Amazon Web Services,Amazon S3,我需要重命名一些S3对象(从xxx.JPG到xxx.JPG) 因为我们不能使用.NET AWSSDK.S3 API重命名它们,所以我用不同的密钥名复制了这些文件 新对象在S3控制台上列出,但我无法访问它们的URL(“公开”按钮也不起作用) 原始对象具有“服务器端加密:无”,但新对象具有“服务器端加密:拒绝访问”,如S3控制台所示 我只是不明白为什么新的服务器会得到这种服务器端加密。我甚至不知道这是否是我无法访问他们的URL的原因 我的C#代码: 我甚至设置bucket public只是为了确保这

我需要重命名一些S3对象(从xxx.JPG到xxx.JPG)

因为我们不能使用.NET AWSSDK.S3 API重命名它们,所以我用不同的密钥名复制了这些文件

新对象在S3控制台上列出,但我无法访问它们的URL(“公开”按钮也不起作用)

原始对象具有“服务器端加密:无”,但新对象具有“服务器端加密:拒绝访问”,如S3控制台所示

我只是不明白为什么新的服务器会得到这种服务器端加密。我甚至不知道这是否是我无法访问他们的URL的原因

我的C#代码:

我甚至设置bucket public只是为了确保这不是我无法访问新对象的原因。没有成功


你们知道我做错了什么吗???CannedACL=S3CannedACL.PublicRead试着传递一个
BucketOwnerFullControl
这些桶在两个不同的AWS帐户中吗?请参阅检查所有权信息。它们位于同一帐户中。实际上,在同一个bucket和文件夹中。它们都具有相同的所有权
<Error>
   <script id="tinyhippos-injected"/>
   <Code>AccessDenied</Code>
   <Message>Access Denied</Message>
   <RequestId>496D3070***</RequestId>
   <HostId>
      zZOOgc5BCSmdIwaTy/wyOKHPU/xo32feTwfW***
   </HostId>
</Error>
private const string sourceBucket = "***";
private const string destinationBucket = "***";
private const string objectKey = "***/image.JPG";
private const string destObjectKey = "***/image.jpg";

private static readonly RegionEndpoint bucketRegion = RegionEndpoint.SAEast1;
private static IAmazonS3 s3Client;

private static async Task CopyingObjectAsync()
{
    try
    {
        s3Client = new AmazonS3Client("***", "***", RegionEndpoint.SAEast1);

        CopyObjectRequest request = new CopyObjectRequest
        {
            SourceBucket = sourceBucket,
            SourceKey = objectKey,
            DestinationBucket = destinationBucket,
            DestinationKey = destObjectKey,
            ServerSideEncryptionMethod = ServerSideEncryptionMethod.None,

        };
        CopyObjectResponse response = await s3Client.CopyObjectAsync(request);
    }
    catch (AmazonS3Exception e)
    {
        Console.WriteLine("Error encountered on server. Message:'{0}' when writing an object", e.Message);
    }
    catch (Exception e)
    {
        Console.WriteLine("Unknown encountered on server. Message:'{0}' when writing an object", e.Message);
    }
}

static void Main(string[] args)
{
    s3Client = new AmazonS3Client(bucketRegion);
    Console.WriteLine("Copying an object");
    CopyingObjectAsync().Wait();
}