AWS S3 PHP getObject标准示例,导致致命错误

问题描述 投票:0回答:2

我有一些看起来完全像这样的代码:

$result = $client->getObject(array(
   'Bucket' => $bucket,
   'Key'    => 'data.txt',
   'SaveAs' => '/tmp/data.txt'
));

其此处列出的示例之一:http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_getObject

不幸的是,我收到此致命错误:

PHP Warning:  Missing argument 2 for AmazonS3::get_object() in /var/www/CronJobs/aws-sdk-    for-php/services/s3.class.php on line 1489
PHP Notice:  Undefined variable: filename in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 1495
PHP Warning:  preg_match() expects parameter 2 to be string, array given in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 1042
PHP Warning:  preg_match() expects parameter 2 to be string, array given in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 1043
PHP Notice:  Array to string conversion in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 548
PHP Fatal error:  Uncaught exception 'S3_Exception' with message 'S3 does not support "Array" as a valid bucket name. Review "Bucket Restrictions and Limitations" in the S3 Developer Guide for more information.' in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php:548
Stack trace:
0 /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php(1530): AmazonS3->authenticate(Array, Array)
1 [internal function]: AmazonS3->get_object(Array)
2 /var/www/CronJobs/aws-sdk-for-php/sdk.class.php(436): call_user_func_array(Array, Array)
3 /var/www/CronJobs/leefomatic/index.php(70): CFRuntime->__call('getObject', Array)
4 /var/www/CronJobs/leefomatic/index.php(70): AmazonS3->getObject(Array)
5 {main}
thrown in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 548

在我的脚本中,我目前是listObject,copy_object和delete_option就好了。关于为何在getObject上出现致命错误的任何想法?

谢谢。

php amazon-web-services amazon-s3 fatal-error method-call
2个回答
0
投票

似乎您正在使用SDK 2.x代码使用SDK 1.x文档。您显示的错误块中的文件名(例如s3.class.phpsdk.class.php)输出肯定表明您正在使用SDK 1.x代码。您需要安装更新更好的受支持的SDK 2.x(here are some instructions),或使用SDK 1.x docs


0
投票

异常信息:S3不支持将“ Array”作为有效的存储桶名称-> s3不支持“数组”作为有效的桶名,可能您放置的桶是一个堆积类型,他qidaide

© www.soinside.com 2019 - 2024. All rights reserved.