dongmu5246 2017-06-11 20:39
浏览 46

Amazon S3多部件上载返回NULL

I am trying to upload an 8GB file, but it constantly returns null. I also do not get an error message no exceptions thrown. The null is displayed in the va_dump, the normal s3 -> putObject works fine with files under 5GB. My code is the following:

$s3 = S3Client::factory(array(
            'credentials' => array(
                'secret' => 'xxx',
                'key' => 'xxxxx'
            ),
            'region' => 'us-west-2',
            'version' => '2006-03-01'
        ));;

        try {

            if(filesize($body) < 5000000000) {

                $result = $s3->putObject(array(
                    'Bucket'       => $bucket,
                    'Key'          => $obect,
                    'SourceFile'   => $body,
                    'ContentType'  => $content_type,
                    'ACL'          => $acl,
                ));

                return $result['ObjectURL'];

            } else {

                echo 'Starting Uploads';

                $source = fopen($body, 'rb');

                $uploader = new MultipartUploader($s3, $source
                , [
                    'bucket' => $bucket,
                    'key'    => $obect,
                    'acl'    => $acl,
                    'concurrency' => 5,
                    'part_size' => (100 * 1024 * 1024),
                    'before_initiate' => function(\Aws\Command $command) use ($content_type) {
                        $command['ContentType'] = $content_type;  //  video/mp4
                    }
                ]);

                echo 'Into Upload';

                $result = $uploader->upload();

                echo 'Complete Upload';

                var_dump($result);

                return (isset($result['Location'])) ? $result['Location'] : false;

            }
        } catch (MultipartUploadException $e) {
            error_log($e -> getMessage() . ' ' . $e -> getTraceAsString());
             $uploader = new \Aws\S3\MultipartUploader($s3, $body, [
                'state' => $e->getState(),
             ]);

            return false;
        } catch (Aws\Exception\S3Exception $e) {
            error_log($e -> getMessage() . ' ' . $e -> getTraceAsString());
            return false;
        } catch (Exception $e) {
            error_log($e -> getMessage() . ' ' . $e -> getTraceAsString());
            return false;
        }

        return false;
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BP神经网络控制倒立摆
    • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
    • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算