ux-nl/
flysystem-uploadcare
g4t.io

Uploadcare Filesystem Adapter for Laravel

18 views 18 stars by Paul Redmond

Uploadcare Flysystem adapter

files flysystem flysystem-adapter laravel php uploadcare uploadcare-api uploads
README from ux-nl/flysystem-uploadcare Open on GitHub →

Laravel Uploadcare integration Filesystem (Flysystem adapter)

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Flysystem adapter for Uploadcare with support for Laravel v9+ including Laravel 13.

Installation

You can install the package via composer:

composer require vormkracht10/flysystem-uploadcare

Add the following config to the disk array in config/filesystems.php

[
    'uploadcare' => [
        'driver' => 'uploadcare',
        'public' => env('UPLOADCARE_PUBLIC_KEY'),
        'secret' => env('UPLOADCARE_SECRET_KEY'),
        'cdn' => env('UPLOADCARE_CDN') // Default https://ucarecdn.com
    ]
]

Then set the FILESYSTEM_DISK to uploadcare and set your public/secret keys in your .env

UPLOADCARE_PUBLIC_KEY=
UPLOADCARE_SECRET_KEY=
FILESYSTEM_DISK=uploadcare

Examples

Please note: Since adding files to uploadcare always returns a unique id that will be used to retrieve files you might wanna use the *GetUuid() function(s) for writing files.

$uuid = Storage::disk('uploadcare')->putGetUuid('example.txt', 'My notes.');

$uuid = Storage::disk('uploadcare')->putFileGetUuid('files', new File('/var/www/uploadcare-app/routes/newcontent.txt'));

$uuid = Storage::disk('uploadcare')->putFileAsGetUuid('files', new File('/var/www/uploadcare-app/routes/newcontent.txt'), 'my-awesome-name.txt');

Get the content of a file

$contents = Storage::disk('uploadcare')->get('<uuid>');

Deleting a file:

Storage::disk('uploadcare')->delete('<uuid>');

Getting the mimetype of a file

$mimeType = Storage::disk('uploadcare')->mimeType('<uuid>');

Get the filesize of a file

$bytes = Storage::disk('uploadcare')->filesize('<uuid>');

Get the original filename

$info = Storage::disk('uploadcare')->fileInfo($result[0]);
$filename = $info->extraMetadata()['originalFilename'];

Get a list of files

Directories in uploadcare are stored with an "~"-sign at the end of a uuid. Getting files from a directory could be retreived as follow:

$files = Storage::disk('uploadcare')->files('0123a456-a0bc-0a1b-0ab1-0a1234a5b6c7~');
foreach ($files as $uuid) {
    echo 'https://ucarecdn.com/' . $uuid .'<br />';
}

Working with images? See github.com/vormkracht10/php-uploadcare-transformations

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

More from the ecosystem

durable-workflow/
workflow
g4t.io
9 1,292

Durable Workflow: Long-Running Workflows for Laravel

Embedded durable workflow runtime and orchestration engine for Laravel applications.

durable-workflow/workflow via Laravel News
packstub/
session-replay
g4t.io
14 52

Session Replay for Laravel: Self-Hosted Browser Recordings

Session replay for Laravel: record what a person did in the browser with rrweb, keep the recording on your own disk and database, and watch it behind a gate you define — masked inputs by default, errors, failed Livewire requests and web vitals marked on the timeline, a link to the replay in every log line. packstub/filament-session-replay adds the sessions to a Filament panel.

packstub/session-replay via Laravel News
cyberwizard-dev/
schedule-catchup
g4t.io
17

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Schedule Catchup replays missed Laravel scheduled tasks after downtime, with opt-in recovery, bounded retries, and access to the original scheduled date.

cyberwizard-dev/schedule-catchup via Laravel News