-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a77935b
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor | ||
/.idea | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 kalax2 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## 简介 | ||
HuaweiCloud OBS filesystem for Laravel | ||
|
||
## 使用方法 | ||
安装 | ||
```shell | ||
composer require kalax2/laravel-huaweicloud-obs | ||
``` | ||
配置 | ||
|
||
```php | ||
// 在config/filesystems.php中添加相应配置 | ||
return [ | ||
|
||
/* 其他配置 */ | ||
|
||
'obs' => [ | ||
'driver' => 'obs', | ||
'access_key' => env('OBS_ACCESS_KEY'), | ||
'access_secret' => env('OBS_ACCESS_SECRET'), | ||
'bucket' => env('OBS_BUCKET'), | ||
'region' => env('OBS_REGION'), // 地域,详见 https://console.huaweicloud.com/apiexplorer/#/endpoint/OBS | ||
'ssl' => env('OBS_SSL', true), // 是否使用https | ||
'domain' => env('OBS_DOMAIN', ''), // 自定义域名 | ||
'guzzle' => [] // GuzzleHttp配置 | ||
] | ||
]; | ||
``` | ||
|
||
使用 | ||
```php | ||
Storage::disk('obs')->put('hello.txt', 'world'); | ||
Storage::disk('obs')->temporaryUrl('hello.txt', now()->addMinutes(5)); | ||
``` | ||
更多用法请看[官方文档](https://laravel.com/docs/11.x/filesystem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "kalax2/laravel-huaweicloud-obs", | ||
"type": "library", | ||
"description": "HuaweiCloud OBS filesystem for laravel.", | ||
"keywords": ["huaweicloud", "obs", "laravel", "filesystem", "storage"], | ||
"require": { | ||
"laravel/framework": "^9.0|^10.0|^11.0", | ||
"kalax2/flysystem-huaweicloud-obs": "^1.0" | ||
}, | ||
"require-dev": { | ||
}, | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Kalax2\\Laravel\\Filesystem\\Obs\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Kalax2\\Laravel\\Filesystem\\Obs\\ObsStorageProvider" | ||
] | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "kalax2" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Kalax2\Laravel\Filesystem\Obs; | ||
|
||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Filesystem\FilesystemAdapter; | ||
use Illuminate\Support\Facades\Storage; | ||
use Illuminate\Support\ServiceProvider; | ||
use League\Flysystem\Filesystem; | ||
use Kalax2\Flysystem\Obs\ObsAdapter; | ||
|
||
class ObsStorageProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
*/ | ||
public function register(): void | ||
{ | ||
Storage::extend('obs', function (Application $app, array $config) { | ||
$adapter = new ObsAdapter( | ||
accessKey: $config['access_key'], | ||
accessSecret: $config['access_secret'], | ||
region: $config['region'], | ||
bucket: $config['bucket'], | ||
config: [ | ||
'ssl' => $config['ssl'], | ||
'domain' => empty($config['domain']) ? null : $config['domain'], | ||
'guzzle' => $config['guzzle'] | ||
] | ||
); | ||
|
||
return new FilesystemAdapter(new FileSystem($adapter), $adapter); | ||
}); | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
*/ | ||
public function boot(): void | ||
{ | ||
// | ||
} | ||
} |