首页 > 解决方案 > 适用于 PHP 的 AWS 开发工具包,上传图像返回 500 内部服务器错误

问题描述

我正在尝试使用 AWS PHP SDK 上传图像。出于某种奇怪的原因,有些图片没有上传?

$s3 = new Aws\S3\S3Client([
            'region'  => 'us-east-1',
            'version' => 'latest',
            'endpoint' => 'https://example.com',
            'use_path_style_endpoint' => true,
            'credentials' => [
                'key'    => $access_key,
                'secret' => $secret,
            ]
        ]);     


        try {

            $result = $s3->putObject([
                'Bucket' => $bucket,
                'Key'    => $file_name,
                'Body' => fopen($file_location, 'r'),
                'ContentType' => $imageType,
                'ACL'   => 'public-read'    
            ]);

        } catch(Aws\S3\Exception\S3Exception $e) {

            echo $e->getMessage();
        }

我可以从 dummyimage.com 下载图像,它会成功上传到存储桶,但是当我尝试其他图像时,s3 返回 500 内部服务器错误。

我该如何解决?错误日志中没有任何内容。

标签: amazon-s3aws-php-sdk

解决方案


推荐阅读