我正在将图片从PHP
上传到 Amazon S3 服务器
它存储成功但我无法打开图像;我收到了这个错误:
无法显示图像“https://s3.amazonaws.com/buckename/24aaffa670e634a7da9a087bfa83abe6_400x400.png”,因为它包含错误。
这是我的代码:
$sourcePath = $_FILES['filedata']['tmp_name'];
$actual_image_name='dinesh'.$_FILES['filedata']['name'];
$contentType= $_FILES['filedata']['type'];
S3::putObject($sourcePath,
BUCKETNAME,
baseName($actual_image_name),
S3::ACL_PUBLIC_READ,array(),
array('Content-Type' =>$contentType))
答案 0 :(得分:0)
$value="SampleVideo1.mp4";
$disk = \Storage::disk('s3');
if ($disk->exists($value))
{
$command = $disk->getDriver()->getAdapter()->getClient()->getCommand(
'GetObject', [
'Bucket' => \Config::get('filesystems.disks.s3.bucket'),
'Key' => $value,
]);
$request = $disk->getDriver()->getAdapter()->getClient()->createPresignedRequest($command, '+10 minutes');
$generate_url = $request->getUri();
echo $generate_url;
}