用php问题将文件上传到amazon s3(Uncaught exception'Guzzl)

时间:2016-09-02 10:02:32

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

我使用amazon s3服务器使用php上传文件。 我试过这段代码

尝试{

    //Accessing config variable
    $s3->putObject([
            'Bucket' => $config['s3']['bucket'],
            'Key' => "uploads/{$name}", //Where we actually store this on amazon S3. CAN USE $TMP_NAME
            'Body' => fopen($tmp_file_path, 'rb'), //Resource, open files - rb is reading.
            'ACL' => 'public-read' //Access control level, permissions as such
        ]);

    //Remove the file
    unlink($tmp_file_path);

} catch (S3Exception $e) {
    die("There was an error uploading that file.");
}

        but getting error as Fatal error: Uncaught exception 'Guzzle\Service\Exception\ValidationException' with message 'Validation errors: [Key] is a required string' in D:\php\htdocs\project\admin\server\aws2\ee\TestUploadAmazon\vendor\guzzle\guzzle\src\Guzzle\Service\Command\AbstractCommand.php:357 Stack trace: #0 

0 个答案:

没有答案