bryanthw1020 / cos-file-uploader
Laravel 使用腾讯COS服务集成的文件上传。
0.0.1
2019-12-02 02:02 UTC
Requires
- qcloud/cos-sdk-v5: >=2.0
Requires (Dev)
- orchestra/testbench: ^4.0
This package is auto-updated.
Last update: 2024-09-30 01:34:41 UTC
README
Laravel 使用腾讯COS服务集成的文件上传
安装
要安装,运行 composer require bryanthw1020/cos-file-uploader
。
安装后,运行 php artisan vendor:publish
以发布配置文件。
发布配置后,请确保将以下两个变量添加到您的 env
文件中
TC_COS_SECRET_ID=
TC_COS_SECRET_KEY=
用法
以下是可用的方法。
# To Upload Object CosFileUploader::uploadObject(string $bucket, string $key, string $fileName, string $base64EncodedFile, string$region = 'ap-singapore', string $schema = 'http'); ## Example CosFileUploader::uploadObject('example-bucket-123456', 'example/file/path', 'example.jpg', $base64EncodedFile); # To Delete Single Object CosFileUploader::deleteObject(string $bucket, string $key, string $region = 'ap-singapore', string $schema = 'http'); ## Example CosFileUploader::deleteObject('example-bucket-123456', 'example/file/path/example.jpg'); # To Delete Multiple Object CosFileUploader::deleteObjects(string $bucket, array $keys, string $region = 'ap-singapore', string $schema = 'http'); ## Example CosFileUploader::deleteObjects('example-bucket-123456', ['example/file/path/example1.jpg', 'example/file/path/example2.jpg']); # To Get Object URL CosFileUploader::getObjectUrl(string $bucket, string $key, int $duration = 10, string $region = 'ap-singapore', string $schema = 'http'); ## Example CosFileUploader::getObjectUrl('example-bucket-123456', 'example/file/path/example.jpg');