【问题标题】:Error: Operation not found: PutObject - during file upload to s3错误:找不到操作:PutObject - 在文件上传到 s3 期间
【发布时间】:2018-02-21 14:24:38
【问题描述】:

我正在尝试将 csv 文件从表单上传到我的 s3 存储桶。一切似乎都很好。但我收到错误消息“找不到操作:PutObject”。下面是我的实现。

    <?php


include 'vendor/autoload.php';

use Aws\Ses\SesClient;
use Aws\S3\Exception\S3Exception;


 $expected_filename = $_FILES['file']['tmp_name'];

 try{


    $client = SesClient::factory(array(
            'version'   => 'latest',
            'region'    => 'eu-west-1',
            'credentials' => array(
              'key'       => 'mykey************',
              'secret'    => 'mysecret***************',
            ),
          ));


          $client->putObject([
              'Bucket' => "s3://bitb/bitb2/",
              'Key'    => $expected_filename,
              'SourceFile' => $expected_filename,
          ]);

}
catch( Exception $x )
{
    echo "Error: " . $x->getMessage() . "\n";

}
?>

【问题讨论】:

  • 我认为您可能缺少以下内容:use Aws\S3\S3Client;

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


【解决方案1】:

在 php 文件的开头添加以下指令:

use Aws\S3\S3Client;

您的语法正确,但您缺少 SDK 中对 S3 库的引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    相关资源
    最近更新 更多