当前位置:网站首页>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-v5Two 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:cache5、 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
}


边栏推荐
- 职场经历反馈给初入职场的程序员
- SubGHz, LoRaWAN, NB-IoT, 物联网
- Storage of dental stem cells (to be continued)
- CTFshow--常用姿势
- 980. Different path III DFS
- 原生小程序 之 input切換 text與password類型
- Career experience feedback to novice programmers
- Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
- [daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree
- On the difference between FPGA and ASIC
猜你喜欢

Jcmd of JVM command: multifunctional command line

3531. 哈夫曼树

SAP Spartacus checkout 流程的扩展(extend)实现介绍

Opensergo is about to release v1alpha1, which will enrich the service governance capabilities of the full link heterogeneous architecture

VScode进行代码补全

@pathvariable 和 @Requestparam的详细区别

3428. 放苹果

Add salt and pepper noise or Gaussian noise to the picture

Apple CMS V10 template /mxone Pro adaptive film and television website template

Bypass open_ basedir
随机推荐
Add salt and pepper noise or Gaussian noise to the picture
Check point: the core element for enterprises to deploy zero trust network (ztna)
驱动开发中platform设备驱动架构详解
Jinfo of JVM command: view and modify JVM configuration parameters in real time
SAP Spartacus checkout 流程的扩展(extend)实现介绍
@Detailed differences between pathvariable and @requestparam
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
Flask1.1.4 werkzeug1.0.1 source code analysis: start the process
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core
【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
Cf:c. column swapping [sort + simulate]
为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
The solution of a simple algebraic problem
你不知道的互联网公司招聘黑话大全
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
[SQL practice] a SQL statistics of epidemic distribution across the country
PowerPivot - DAX (function)
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core