Error: Operation not found: PutObject - during file upload to s3

Error: Operation not found: PutObject - during file upload to s3

我正在尝试将一个 csv 文件从表单上传到我的 s3 存储桶。一切似乎都是 fine.but 我收到错误消息 "Operation not found: 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";

}
?>

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

use Aws\S3\S3Client;

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