aws上传文件及配置
2021-03-20 16:25
标签:request ace 获取 red except inf creat 文件 phpstudy php.in 最后一页 配置cacert.pem证书文件,否则解析不了aws存储桶的路由 curl.cainfo = D:/phpstudy_pro/cacert.pem 引入 use Aws\S3\S3Client; //aws认证 $credentials = new Aws\Credentials\Credentials(‘key‘, ‘secret‘); $S3Client= new Aws\S3\S3Client([ //存储桶列表 $S3Client->listbuckets(); //获取对象列表 $bucket=‘‘;//存储桶 $S3Client->listObject(‘bucket‘=>‘aws.bucket‘); //分段上传文件 $source=‘../images/111.png‘;//文件路径 $photo_name=‘test.png‘;//文件上传名字 $S3Client = new Aws\S3\MultipartUploader($S3Client, $source, [ //预签名获取文件路由 $cmd = $S3Client->getCommand(‘GetObject‘, [ aws上传文件及配置 标签:request ace 获取 red except inf creat 文件 phpstudy 原文地址:https://www.cnblogs.com/jiangjie050/p/12736189.html
use Aws\S3\Exception\S3Exception;
‘version‘ =>‘aws.version‘,//存储桶地区
‘region‘ =>‘2006-03-01‘,//日期
‘credentials‘ => $credentials
]);
‘bucket‘ =>‘aws.bucket‘,
‘key‘ => $photo_name,
]);
try {
$result = $S3Client->upload();
return $result[‘Key‘];
} catch (MultipartUploadException $e) {
return $e->getMessage() . "\n";
}
‘Bucket‘ =>‘aws.bucket‘,
‘Key‘ => $key //aws文件健名
]);
$request = $config->createPresignedRequest($cmd, ‘+20 minutes‘);
$presignedUrl = (string)$request->getUri();
上一篇:Vue 修改网页标题和图标
下一篇:模仿NetFlix首页效果