joschaefer/flysystem-sciebo

Sciebo 的 Flysystem 适配器

v1.3.1 2022-09-17 08:59 UTC

This package is auto-updated.

Last update: 2024-09-17 13:32:33 UTC


README

此包包含一个 Flysystem v3 适配器,用于 Sciebo,Sciebo 是北莱茵-威斯特法伦州(德国)大学提供的基于 ownCloud 的非商业文件托管服务。API 基于WebDAV协议。

安装

您可以通过 composer 安装此包

composer require joschaefer/flysystem-sciebo

使用方法

先决条件

首先获取访问您的 Sciebo 存储的凭证

  1. 登录 Sciebo
  2. 点击右上角的用户名并转到 设置
  3. 转到 安全 选项卡
  4. 为您的应用程序输入一个名称并点击 创建新的应用程序密码
  5. 保存创建的凭证以备后用

基本使用

<?php

use Joschaefer\Flysystem\Sciebo\ScieboAdapter;
use Joschaefer\Flysystem\Sciebo\ScieboClient;
use League\Flysystem\Filesystem;

include __DIR__ . '/vendor/autoload.php';

$client = new ScieboClient('rwth-aachen', 'ABC123@rwth-aachen.de', 'your-secret-app-passcode');
$adapter = new ScieboAdapter($client);
$filesystem = new Filesystem($adapter);

Laravel

如果您在一个 Laravel 项目中使用此适配器,请在 app/Providers/AppServiceProvider.php 中添加以下内容

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use Joschaefer\Flysystem\Sciebo\ScieboAdapter;
use Joschaefer\Flysystem\Sciebo\ScieboClient;
use League\Flysystem\Filesystem;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // ...
        
        Storage::extend('sciebo', function ($app, $config) {
            $adapter = new ScieboAdapter(
                new ScieboClient($config['node'], $config['username'], $config['password']),
                $config['prefix']
            );

            return new FilesystemAdapter(
                new Filesystem($adapter, $config),
                $adapter,
                $config
            );
        });
    }
}

之后,您需要像这样扩展 config/filesystems.php 中的配置

<?php

return [

    // ...

    'disks' => [

        // ...

        'sciebo' => [
            'driver' => 'sciebo',
            'node' => env('SCIEBO_NODE', ''),
            'username' => env('SCIEBO_USERNAME', ''),
            'password' => env('SCIEBO_PASSWORD', ''),
            'prefix' => env('SCIEBO_PREFIX'),
        ],

    ],

    // ...

];

最后将您的配置添加到您的 .env 文件中

SCIEBO_NODE=rwth-aachen
SCIEBO_USERNAME=ABC123@rwth-aachen.de
SCIEBO_PASSWORD=your-secret-app-passcode

安全

如果您发现任何安全问题,请通过电子邮件 mail@johannes-schaefer.de 联系我们,而不是使用问题跟踪器。

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件