PHP code example of lorine / oss-utils
1. Go to this page and download the library: Download lorine/oss-utils library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lorine / oss-utils example snippets
composer
use Lorine\OssUtils\OssService;
$config = [
'ak' => 'xxxxxx',//SecretId /Access_Key
'sk' => 'xxxxxx',//SecretKe /Secret_Key
'bucket' => 'xxxxx',//桶名
'region' => ''//地区 七牛云为'',腾讯云在控制台对象存储界面获取,如上海(ap-shanghai)
];
try {
//云存储类型 腾讯云:Tencent 七牛云:Qiniu
$obj = (new OssService())->getOssService('Tencent');
//$tmpName绝对路径
//$fileName自定义云储存的文件名称
$res = $obj->uploadFile($config,$tmpName,$fileName);
dd($res);
}catch (Exception $exception){
dd($exception->getMessage());
}