edrisaturay/laravel-kdrive

Infomaniak kDrive Storage driver for Laravel. Fork of infomaniak/laravel-kdrive, modernized for Flysystem v3 and Laravel 11/12/13.

Maintainers

Package info

github.com/edrisaturay/laravel-kdrive

pkg:composer/edrisaturay/laravel-kdrive

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-07-27 14:32 UTC

This package is auto-updated.

Last update: 2026-07-27 14:58:57 UTC


README

An Infomaniak kDrive Storage driver for Laravel, exposing kDrive as a standard Storage disk over WebDAV.

This is a fork of infomaniak/laravel-kdrive by Nicolas Hedger, modernized for Flysystem v3 and Laravel 11/12/13 (the upstream package and its infomaniak/flysystem-kdrive adapter are abandoned and Flysystem v1 only).

Requirements

  • PHP ^8.2
  • Laravel ^11.0 | ^12.0 | ^13.0

Installation

Installed in this monorepo via a path repository in the root composer.json:

{
    "repositories": [
        { "type": "path", "url": "packages/edrisaturay/laravel-kdrive", "options": { "symlink": true } }
    ]
}
composer require edrisaturay/laravel-kdrive:*

The service provider is auto-discovered.

Configuration

Set your credentials in .env:

KDRIVE_ID=123456
KDRIVE_USERNAME=you@example.com
KDRIVE_PASSWORD=your-application-password
KDRIVE_PREFIX=
  • KDRIVE_ID — your kDrive numeric id (the number after /drive/ in the kDrive web app URL).
  • KDRIVE_USERNAME — the email used to sign in to your Infomaniak account.
  • KDRIVE_PASSWORD — an application password (required when two-step authentication is enabled).
  • KDRIVE_PREFIX — optional path within the drive to scope the disk to, e.g. Common documents/uploads.

Add the disk to config/filesystems.php:

'disks' => [
    // ...
    'kdrive' => [
        'driver'   => 'kdrive',
        'id'       => config('kdrive.id'),
        'username' => config('kdrive.username'),
        'password' => config('kdrive.password'),
        'prefix'   => config('kdrive.prefix'),
    ],
],

Optionally publish the package config:

php artisan vendor:publish --tag=kdrive-config

Usage

use Illuminate\Support\Facades\Storage;

Storage::disk('kdrive')->put('reports/june.pdf', $contents);
$contents = Storage::disk('kdrive')->get('reports/june.pdf');

It behaves like any other Laravel filesystem disk.

Filament integration

Because kdrive is registered as a standard Laravel disk, any Filament v5 component that accepts a disk name works out of the box.

FileUpload (opt-in per field)

use Filament\Forms\Components\FileUpload;

FileUpload::make('attachment')
    ->disk('kdrive')
    ->directory('uploads')
    ->visibility('private');

To make it the default for every FileUpload in a panel, add this to a service provider's boot() method:

use Filament\Forms\Components\FileUpload;

FileUpload::configureUsing(fn (FileUpload $component) => $component->disk('kdrive'));

SpatieMediaLibraryFileUpload

use Filament\Forms\Components\SpatieMediaLibraryFileUpload;

SpatieMediaLibraryFileUpload::make('gallery')
    ->collection('gallery')
    ->disk('kdrive');

Spatie Media Library integration

spatie/laravel-medialibrary is a first-class consumer of Laravel disks, so kDrive plugs in with a single environment variable — no code changes required.

1. Set the default media disk

In .env:

MEDIA_DISK=kdrive

config/media-library.php already reads env('MEDIA_DISK', 'public').

2. Per-model / per-collection override

If you'd rather keep the default disk as public and only route specific collections to kDrive:

use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

class Document extends Model implements HasMedia
{
    use InteractsWithMedia;

    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('originals')->useDisk('kdrive');
    }
}

Attaching a file:

$document->addMedia($request->file('file'))->toMediaCollection('originals');

3. Conversions

If you generate image conversions and want them on a different (typically faster, local) disk, set:

MEDIA_CONVERSIONS_DISK=public

Media Library will store originals on kdrive and conversions on public.

Notes & caveats

  • kDrive is a WebDAV backend — expect noticeably higher latency than local/S3. For write-heavy workflows (e.g. lots of image conversions), consider using kDrive only for archival/originals and keeping conversions on a local/CDN disk.
  • Public URLs: kDrive files are not publicly accessible by default. Use Storage::disk('kdrive')->temporaryUrl(...) only if you've implemented a signed-URL flow; otherwise stream files through a controller.
  • Direct browser uploads (Livewire/Filament temporary uploads) still go through your app server first — the file lands on kDrive on the final store call, not on the initial temp upload.

Credits

License

The MIT License (MIT). See LICENSE.md.