AWS s3Client-> copyObject成功,但是复制的对象丢失是乱码

时间:2018-07-27 11:51:51

标签: php amazon-web-services amazon-s3 aws-php-sdk

请协助。 我使用以下代码段成功将对象上传到S3:

    // Send a PutObject request and get the result object.
    $result = $this->s3EncryptionClient->putObject([
        '@MaterialsProvider' => $this->materialsProvider,
        '@CipherOptions' => $this->cipherOptions,
        'Bucket' => $this->s3BucketName,
        'Key'    => $key,
        'ContentType' => $mimeType,
        'ContentLength' => filesize($filePath),
        'ContentDisposition' => "attachment; filename='" . $fileName . "'",
        'Body' => fopen($filePath ,'r')
    ]);

我可以使用以下代码段成功下载对象:

    // Download the contents of the object.
    $result = $this->s3EncryptionClient->getObject([
        '@MaterialsProvider' => $this->materialsProvider,
        '@CipherOptions' => $this->cipherOptions,
        'Bucket' => $this->s3BucketName,
        'Key'    => $key 
    ]);

当我尝试使用以下代码片段复制对象时出现问题:

    $result = $this->s3Client->CopyObject([
        'Bucket' => $this->s3BucketName,
        'CopySource' => $CopySource,
        'Key' => $dstKey,
    ]);

该对象似乎被错误地复制,并且当我尝试使用我在本文前面粘贴的下载代码下载新对象时,找不到该对象,并且出现了AWSException

  

导致404 Not Found响应

您知道如何解决该问题吗?

0 个答案:

没有答案