0

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

$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 会出现致命错误的任何想法?

谢谢。

4

1 回答 1

0

看起来您正在使用带有SDK 1.x代码的SDK 2.x文档。您显示的错误块中的文件名(例如 , )输出明确表明您正在使用 SDK 1.x 代码。您要么需要安装更新且支持更好的 SDK 2.x(这里有一些说明),要么使用SDK 1.x 文档s3.class.phpsdk.class.php

于 2013-10-01T21:34:56.490 回答