当前位置:网站首页>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
}
边栏推荐
- Jcmd of JVM command: multifunctional command line
- How to improve website weight
- Introduction to the extension implementation of SAP Spartacus checkout process
- jvm命令之 jcmd:多功能命令行
- Classic questions about data storage
- JVM命令之 jinfo:实时查看和修改JVM配置参数
- 从“跑分神器”到数据平台,鲁大师开启演进之路
- VScode进行代码补全
- 【SQL实战】一条SQL统计全国各地疫情分布情况
- 10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
猜你喜欢
On the discrimination of "fake death" state of STC single chip microcomputer
JVM命令之 jinfo:实时查看和修改JVM配置参数
Jinfo of JVM command: view and modify JVM configuration parameters in real time
Interview skills of software testing
Jstat of JVM command: View JVM statistics
POI excel export, one of my template methods
laravel 使用腾讯云 COS5全教程
一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
Convert numbers to string strings (to_string()) convert strings to int sharp tools stoi();
From "running distractor" to data platform, Master Lu started the road of evolution
随机推荐
SubGHz, LoRaWAN, NB-IoT, 物联网
693. 行程排序
外设驱动库开发笔记43:GPIO模拟SPI驱动
What EDA companies are there in China?
改变ui组件原有样式
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
JVM监控及诊断工具-命令行篇
Industrial Finance 3.0: financial technology of "dredging blood vessels"
C note 13
jvm命令之 jcmd:多功能命令行
Jmeter自带函数不够用?不如自己动手开发一个
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取
驱动开发中platform设备驱动架构详解
ML's shap: Based on the adult census income binary prediction data set (whether the predicted annual income exceeds 50K), use the shap decision diagram combined with the lightgbm model to realize the
一个简单的代数问题的求解
PTA TIANTI game exercise set l2-003 moon cake test point 2, test point 3 Analysis
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
JVM monitoring and diagnostic tools - command line
POI excel export, one of my template methods
SAP ABAP BDC (batch data communication) -018