whereof / laravel-filesystem-github
1.0.0
2022-03-19 13:04 UTC
Requires
- php: >=7.2
- whereof/flysystem-github: ^1.0
This package is auto-updated.
Last update: 2023-03-07 07:58:35 UTC
README
Github存储,基于whereof/flysystem-github。
要求
- PHP >= 7.2
安装
composer require whereof/laravel-filesystem-github -vvv
配置
- 安装库之后,在您的
config/app.php
文件中注册whereof\laravel\filesystem\github\GithubStorageServiceProvider
'providers' => [
// Other service providers...
whereof\laravel\filesystem\github\GithubStorageServiceProvider::class,
],
- 在
config/filesystems.php
配置中添加一个新的磁盘
<?php
return [
'disks' => [
//...
'github' => [
'driver' => 'github',
'token' => env('GITHUB_TOKEN', 'xxxxxxxxxxxxxxxx'),
'username' => env('GITHUB_USERNAME', 'xxxxxxxxxxxxxxxx'),
'repository' => env('GITHUB_REPOSITORY', 'test'),
],
//...
]
];
使用
$disk = Storage::disk('qiniu');
// create a file
$disk->put('avatars/filename.jpg', $fileContents);
// check if a file exists
$exists = $disk->has('file.jpg');
// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');
// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');
// get file contents
$contents = $disk->read('folder/my_file.txt');
// get file url
$url = $disk->getUrl('folder/my_file.txt');