自己简单封装了一个composer包
composer require lorine/oss-utils
示例
use Lorine\OssUtils\OssService;
public function upload(Request $request)
{
$file = $request->file('file');
$tmpName = $file->getPathname();//上传文件的本地路径
$fileName = time().'.'.$file->extension();//自定义云存储文件名
//使用
$config = [
'ak' => config('oss.qiniu.ak'),//SecretId Access_Key
'sk' => config('oss.qiniu.sk'),//SecretKe Secret_Key
'bucket' => config('oss.qiniu.bucket'),//桶名
'region' => ''//地区 七牛云为'',腾讯云在控制台对象存储界面获取,如上海'ap-shanghai'
];
try {
//云存储类型 腾讯云:Tencent 七牛云:Qiniu
$obj = (new OssService())->getOssService('Qiniu')