在对sr bucket使用createPresignedUrl()函数时遇到错误。
$s3Client = new S3($awsAccessKey, $awsSecretKey);
$command = $s3Client->getObject($bucket, $filename);
$request = $s3Client->createPresignedUrl($command, '+1 minutes');
// Get the actual presigned-url
$presignedUrl = (string)$request->getUri();
答案 0 :(得分:0)
您可以执行以下操作
include_once('../aws/aws-autoloader.php');
$s3Client = new Aws\S3\S3Client([
'version' => '2006-03-01', // Change as per your version
'region' => 'ap-south-1', // Change as per your region
'credentials' => [
'key' => ACCESS_KEY_ID, // Your access key
'secret' => SECRET_ACCESS_KEY, // Your secret key
],
]);
$cmd = $s3Client->getCommand('GetObject', [
'Bucket' => BUCKET_NAME,
'Key' => $file
]);
$request = $s3Client->createPresignedRequest($cmd, '+' . (60 * 24 * 7) . ' minutes');
$presignedUrl = (string) $request->getUri(); // here you got URL