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


边栏推荐
- SQL Server 2008 各种DateTime的取值范围
- SAP ABAP BDC (batch data communication) -018
- The boss always asks me about my progress. Don't you trust me? (what do you think)
- Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
- 10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
- SAP Spartacus checkout 流程的扩展(extend)实现介绍
- 一个简单的代数问题的求解
- Personal imitation SSM framework
- 改变ui组件原有样式
- Red Hat安装内核头文件
猜你喜欢

Jinfo of JVM command: view and modify JVM configuration parameters in real time

@Detailed differences between pathvariable and @requestparam

C note 13

window下面如何安装swoole

Bypass open_ basedir
![Cf:c. column swapping [sort + simulate]](/img/0e/64d17980d3ec0051cdfb5fdb34e119.png)
Cf:c. column swapping [sort + simulate]

From "running distractor" to data platform, Master Lu started the road of evolution

The boss always asks me about my progress. Don't you trust me? (what do you think)

从“跑分神器”到数据平台,鲁大师开启演进之路

Why does the data center need a set of infrastructure visual management system
随机推荐
【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
PowerPivot - DAX (function)
Personal imitation SSM framework
Why does the data center need a set of infrastructure visual management system
Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
window下面如何安装swoole
[云原生]微服务架构是什么?
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”
Data storage 3
Flask1.1.4 werkzeug1.0.1 source code analysis: start the process
驱动开发中platform设备驱动架构详解
Cloud acceleration helps you effectively solve attack problems!
MySQL performance_ Schema common performance diagnosis query
进程间通信之共享内存
Career experience feedback to novice programmers
高并发大流量秒杀方案思路
Storage of dental stem cells (to be continued)
那些自损八百的甲方要求
一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】