Uploadcare Filesystem Adapter for Laravel


May 30th, 2023

Uploadcare Filesystem Adapter for Laravel

The Uploadcare PHP package is an adapter for Flysystem that makes it easy to use the Uploadcare API in Laravel 10+ apps:

$uuid = Storage::disk('uploadcare')
->putGetUuid('example.txt', 'My notes.');
$uuid = Storage::disk('uploadcare')
->putFileGetUuid('files', new File('/path/to/newcontent.txt'));
$uuid = Storage::disk('uploadcare')
new File('/path/to/newcontent.txt'),

To retrieve and manage files from Uploadcare using Flysystem, you provide the UUID of the resource you want to retrieve:

// Get the content of a file
// Delete a file

If you're working with images, the package author has a PHP Uploadcare transformations package that provides image manipulation tools:

use Vormkracht10\UploadcareTransformations\UploadcareTransformation;
$uuid = '12a3456b-c789-1234-1de2-3cfa83096e25';
$cdnUrl = 'https://example.com/cdn/';
$transformation = (new UploadcareTransformation($uuid, $cdnUrl));
$url = $transformation->crop(width: 320, height: '50p', offsetX: 'center')->setFill(color: 'ffffff');
echo $url;

You can install this package via composer with the following command:

composer require vormkracht10/flysystem-uploadcare

The source code contains complete installation instructions and examples of how you can use the Flysystem API with Uploadcare.

This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.