whereof/laravel-filesystem-github

此包已被废弃,不再维护。作者建议使用pkg6/flysystem-github包。

基于GitHub的Laravel存储文件系统。

1.0.0 2022-03-19 13:04 UTC

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

配置

  1. 安装库之后,在您的config/app.php文件中注册whereof\laravel\filesystem\github\GithubStorageServiceProvider
'providers' => [
    // Other service providers...
    whereof\laravel\filesystem\github\GithubStorageServiceProvider::class,
],
  1. 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');

完整API文档。