MultipartUpload错误

时间:2014-11-19 11:51:14

标签: php amazon-s3

我正在使用Amazon S3AWS SDK for PHP

我尝试使用MultiPartUpload上传文件,但我遇到此错误:

  

PHP Catchable致命错误:参数2传递给   Guzzle \ Service \ Client :: getCommand()必须是类型数组,   给出的字符串,在/var/www/html/aws/Guzzle/Service/Client.php上调用   第76行并在/var/www/html/aws/Guzzle/Service/Client.php中定义   第79行

当我同时上传10个以上时会发生此错误。

任何人都知道为什么?

PHP:connection.php

use Aws\Common\Exception\MultipartUploadException;
use Aws\S3\Model\MultipartUpload\UploadBuilder;
use Aws\S3\S3Client;

$uploaded = (object) $_FILES['uploaded_file'];


$this->file  = $uploaded->tmp_name;

$arrayConfig =  array(
            'key'    => $this->accessKey,
            'secret' => $this->secretKey
        );

$this->awsClient = S3Client::factory($arrayConfig);

$uploader = UploadBuilder::newInstance()
            ->setClient($this->awsClient)
            ->setSource($this->file)
            ->setBucket($this->bucket)
            ->setKey($this->file_name_id)
            ->build();

我有一个crontab服务,同时有10个命令:

*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php
*/05 * * * * /usr/bin/php /home/user/upload_test.php

upload_test.php:

$local_file = '/home/user/file.zip';

$ch = curl_init();
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_VERBOSE, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)" );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_URL, 'http://localhost/connection.php' );

$post_array = array(
    "uploaded_file" => "@" . $local_file,
    "function" => "upload"
);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_array );
$response = curl_exec( $ch );

0 个答案:

没有答案