# thinkphp-huawei-obs **Repository Path**: flywit/thinkphp-huawei-obs ## Basic Information - **Project Name**: thinkphp-huawei-obs - **Description**: thinkphp huaweiCloud filesystem|thinkphp6华为云 obs - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2023-02-14 - **Last Updated**: 2023-06-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # thinkphp6 华为云 filesystem 基于 [dscmall/laravel-filesystem-obs](https://github.com/dscmall/laravel-filesystem-obs) 轻度封装tp ## 安装 --- ```shell composer require death_satan/thinkphp-huawei-obs ``` --- ## 初始化 ### 修改配置 *config/filesystem.php* 文件 --- ```php env('filesystem.driver', 'local'), // 磁盘列表 'disks' => [ 'local' => [ 'type' => 'local', 'root' => app()->getRuntimePath() . 'storage', ], 'public' => [ // 磁盘类型 'type' => 'local', // 磁盘路径 'root' => app()->getRootPath() . 'public/storage', // 磁盘路径对应的外部URL路径 'url' => '/storage', // 可见性 'visibility' => 'public', ], //新增一个磁盘 'huawei'=>[ 'type' => 'Huawei',//设置驱动 'key' => env('OBS_ACCESS_ID'), // 'secret' => env('OBS_ACCESS_KEY'), // 'bucket' => env('OBS_BUCKET'), // 'endpoint' => env('OBS_ENDPOINT'), // OBS 外网节点或自定义外部域名 'cdn_domain' => env('OBS_CDN_DOMAIN'), // 如果isCName为true, getUrl会判断cdnDomain是否设定来决定返回的url,如果cdnDomain未设置,则使用endpoint来生成url,否则使用cdn 'ssl_verify' => env('OBS_SSL_VERIFY'), // true to use 'https://' and false to use 'http://'. default is false, 'debug' => env('APP_DEBUG'), // 'prefix'=>'',//prefix ] // 更多的磁盘配置信息 ], ]; ``` --- ## 使用方法 ### 通过filesystem使用 --- ```php //通过门面使用 think\facade\Filesystem::disk('huawei') //在控制器中通过注入使用 class TestControl{ public function Test(\think\Filesystem $filesystem) { $aliyun = $filesystem->disk('huawei'); } } ``` --- ### 文件上传 ```php file('image'); //通过filesystem进行上传 $url = Filesystem::disk('huawei')->putFile('images', $file); if (!$url) new \exception('上传失败'); dd('上传成功,文件位置:' . $url); } } ```