当前位置:网站首页>Laravel uses Tencent cloud cos5 full tutorial
Laravel uses Tencent cloud cos5 full tutorial
2022-07-07 06:12:00 【Life goes on and battles go on】
laravel Use Tencent cloud COS5 Full course
One download
The first step must be to use composer Install the package , Here is laravel5.8 Version of , So I used cos5
composer require freyo/flysystem-qcloud-cos-v5
Two To configure
1、 stay config/app.php Add
'providers' => [
// ...
Freyo\Flysystem\QcloudCOSv5\ServiceProvider::class,
]
2、 To configure config/filesystems.php:
'disks'=>[
// ...
'cosv5' => [
'driver' => 'cosv5',
'region' => env('COSV5_REGION', 'ap-guangzhou'),// In the back is the region set in the console storage bucket
'credentials' => [
'appId' => env('COSV5_APP_ID'),
'secretId' => env('COSV5_SECRET_ID'),
'secretKey' => env('COSV5_SECRET_KEY'),
],
'timeout' => env('COSV5_TIMEOUT', 60),
'connect_timeout' => env('COSV5_CONNECT_TIMEOUT', 60),
'bucket' => env('COSV5_BUCKET'),
'cdn' => env('COSV5_CDN'),
'scheme' => env('COSV5_SCHEME', 'https'),
'read_from_cdn' => env('COSV5_READ_FROM_CDN', false),
],
],
3、 To configure .env: Be careful : hold \\ Take out the back
COSV5_APP_ID=// The console can see appid
COSV5_SECRET_ID=// The console can see SecretId
COSV5_SECRET_KEY=// The console can see SecretKey
COSV5_TIMEOUT=60
COSV5_CONNECT_TIMEOUT=60
COSV5_BUCKET=
COSV5_REGION=ap-guangzhou// The region , If you configure it here, you don't need to config It's equipped with
COSV5_CDN= #https://{your-bucket-name}-{your-app-id}.file.myqcloud.com
COSV5_SCHEME=https
COSV5_READ_FROM_CDN=false
4、 If an error is reported as follows
laravel Driver [] is not supported.
Please be there. cmd Do the following
php artisan config:cache
5、 Get secret key URL : Tencent secret key to get the address
3、 ... and Upload files
public function upload_file(Request $request)
{
// Judge the document
$file = $request->file('file');
if(empty($file))
{
return json_encode(['msg'=>' The file cannot be empty ','status'=>0]);
}
// Upload files
$disk = Storage::disk('cosv5');
$file_content = $disk -> put('video_class',$file);// The first parameter is the path where you want to put the file in the bucket , The second parameter is the file object
$file_url = $disk->url($file_content);// Get the online address of the file
return json_encode(['msg'=>' Upload successful ','status'=>1,'data'=>['file_url' => $file_url]]);// Returns the parameter
}
边栏推荐
- 3428. 放苹果
- Mac version PHP installed Xdebug environment (M1 version)
- @pathvariable 和 @Requestparam的详细区别
- MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
- PTA 天梯赛练习题集 L2-003 月饼 测试点2,测试点3分析
- yarn入门(一篇就够了)
- Find duplicate email addresses
- Financial risk control practice - decision tree rule mining template
- 为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
- @Detailed differences between pathvariable and @requestparam
猜你喜欢
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
win系统下安装redis以及windows扩展方法
可极大提升编程思想与能力的书有哪些?
老板总问我进展,是不信任我吗?(你觉得呢)
window下面如何安装swoole
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
Interview questions and salary and welfare of Shanghai byte
3531. 哈夫曼树
PowerPivot——DAX(函数)
Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
随机推荐
Solve pod install error: FFI is an incompatible architecture
Flask1.1.4 werkzeug1.0.1 source code analysis: start the process
linear regression
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
C note 13
693. 行程排序
New Year Fireworks code plus copy, are you sure you don't want to have a look
Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
Oracle迁移中关于大容量表使用数据泵(expdp、impdp)导出导入容易出现的问题和注意事项
Storage of dental stem cells (to be continued)
3531. 哈夫曼树
PTA ladder game exercise set l2-002 linked list de duplication
Loss function and positive and negative sample allocation in target detection: retinanet and focal loss
[云原生]微服务架构是什么?
MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
cf:C. Column Swapping【排序 + 模擬】
Apple CMS V10 template /mxone Pro adaptive film and television website template
PTA 天梯赛练习题集 L2-003 月饼 测试点2,测试点3分析
老板总问我进展,是不信任我吗?(你觉得呢)