amazon-s3 - 适用于 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 内部服务器错误。
我该如何解决?错误日志中没有任何内容。
解决方案
推荐阅读
- php - 我们如何通过角度上传二进制文件(.bin)并使用代码点火器在后端处理它
- python - 如何在熊猫数据框中获取具有部分总和的列(按两列分组)
- svelte - 如何从 Prismic API 在 Sapper 应用程序中预加载数据
- python - Pygame 在无头 Raspberry Pi Zero(Raspbian Buster Lite)上显示初始化
- elasticsearch - ElasticSearch 中的相等字段值
- mysql - 没有分组依据的 Linq Sum
- kotlin - 从对象外部调用嵌套在对象内部的扩展函数
- javascript - Firefox 控制台在 javascript 代码中显示语法问题
- html - 为什么我已经添加了过渡线,但过渡不起作用?
- javascript - 如何随机排列卡片 javascript