dscmall / laravel-filesystem-cos
A Cos storage filesystem for Laravel.
Installs: 2 688
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 2
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0.1
- qcloud/cos-sdk-v5: ^2.1
This package is auto-updated.
Last update: 2024-12-07 16:19:53 UTC
README
Tencent Cloud COS storage for Laravel
Requirement
- PHP >= 7.1
Installation
$ composer require "dscmall/laravel-filesystem-cos" -vvv
Configuration
- Add a new disk to your
config/filesystems.php
config:
<?php return [ 'disks' => [ //... 'cos' => [ 'driver' => 'cos', 'region' => env('COS_REGION', 'ap-guangzhou'), 'credentials' => [ 'appId' => env('COS_APP_ID'), 'secretId' => env('COS_SECRET_ID'), 'secretKey' => env('COS_SECRET_KEY'), ], 'timeout' => env('COS_TIMEOUT', 60), 'connect_timeout' => env('COS_CONNECT_TIMEOUT', 60), 'bucket' => env('COS_BUCKET'), 'cdn' => env('COS_CDN'), 'scheme' => env('COS_SCHEME', 'https'), 'read_from_cdn' => env('COS_READ_FROM_CDN', false), ], //... ] ];
Usage
$disk = Storage::disk('cos'); // create a file $disk->put('avatars/filename.jpg', $fileContents); // check if a file exists $exists = $disk->has('file.jpg'); // get timestamp $time = $disk->lastModified('file1.jpg'); $time = $disk->getTimestamp('file1.jpg'); // copy a file $disk->copy('old/file1.jpg', 'new/file1.jpg'); // move a file $disk->move('old/file1.jpg', 'new/file1.jpg'); // get file contents $contents = $disk->read('folder/my_file.txt'); // fetch url content $file = $disk->fetch('folder/save_as.txt', $fromUrl); // get file url $url = $disk->getUrl('folder/my_file.txt');
License
MIT