当前位置:网站首页>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
}
边栏推荐
- Vscode for code completion
- Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
- Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
- PTA TIANTI game exercise set l2-003 moon cake test point 2, test point 3 Analysis
- 【GNN】图解GNN: A gentle introduction(含视频)
- Cloud acceleration helps you effectively solve attack problems!
- The boss always asks me about my progress. Don't you trust me? (what do you think)
- 目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
- [云原生]微服务架构是什么?
- Introduction to the extension implementation of SAP Spartacus checkout process
猜你喜欢
高并发大流量秒杀方案思路
你不知道的互联网公司招聘黑话大全
生活中的开销,怎么记账合适
Jstat pour la commande JVM: voir les statistiques JVM
Interview skills of software testing
How to improve website weight
目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU
Peripheral driver library development notes 43: GPIO simulation SPI driver
【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
随机推荐
Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
New Year Fireworks code plus copy, are you sure you don't want to have a look
Value range of various datetimes in SQL Server 2008
Reading notes of Clickhouse principle analysis and Application Practice (6)
@Detailed differences between pathvariable and @requestparam
Redisl garbled code and expiration time configuration
yarn入门(一篇就够了)
Interview questions and salary and welfare of Shanghai byte
PowerPivot——DAX(函数)
JVM命令之 jstat:查看JVM统计信息
A freshman's summary of an ordinary student [I don't know whether we are stupid or crazy, but I know to run forward all the way]
Jcmd of JVM command: multifunctional command line
Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
3531. 哈夫曼树
404 not found service cannot be reached in SAP WebService test
你不知道的互联网公司招聘黑话大全
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
What EDA companies are there in China?
职场经历反馈给初入职场的程序员
SAP Spartacus checkout 流程的扩展(extend)实现介绍