joschaefer/flysystem-sciebo

Flysystem adapter for Sciebo

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

This package is auto-updated.

Last update: 2024-04-17 12:18:12 UTC


README

This package contains a Flysystem v3 adapter for Sciebo, a non-commercial file hosting service based on ownCloud provided by the universities of the state of North Rhine-Westphalia (Germany). The API is based on the WebDAV protocol.

Installation

You can install the package via composer:

composer require joschaefer/flysystem-sciebo

Usage

Prerequisit

First obtain credentials for accessing your Sciebo storage:

  1. Log in to Sciebo
  2. Click on your username in the top-right corner and go to Settings
  3. Go to Security tab
  4. Enter a name for your application and hit Create new app passcode
  5. Store the created credentials for later

Basic usage

<?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

If you are using this adapter in a Laravel project, add the following to 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
            );
        });
    }
}

After that you need to extend the configurations in config/filesystems.php like this:

<?php

return [

    // ...

    'disks' => [

        // ...

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

    ],

    // ...

];

And finally add your config to your .env file:

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

Security

If you discover any security related issues, please email mail@johannes-schaefer.de instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.