使用AWS SDK(PHP)将文件上传到S3 - 无法上传非对象

时间:2015-04-26 16:56:16

标签: php amazon-web-services file-upload

我有以下代码,它正常工作直到使用上传功能。然后我得到错误 -

在非对象上调用成员函数upload()。

我理解错误意味着什么,但我不知道为什么?有任何想法吗。谷歌搜索了zilch。

require('/libs/s3/aws-autoloader.php');

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

// Instantiate an S3 client
$s3Client = S3Client::factory(array(
    'profile' => 'default',
));

    try {
    $resource = fopen(DRUPAL_ROOT . '/LICENSE.txt', 'r');  

    $s3->upload('be-production', 'assets', $resource, 'public-read');
} catch (S3Exception $e) {
    echo "There was an error uploading the file.\n";
}

0 个答案:

没有答案
相关问题