Uploadcare Filesystem Adapter for Laravel
Published on by Paul Redmond
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') ->putFileAsGetUuid( 'files', new File('/path/to/newcontent.txt'), 'my-awesome-name.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 fileStorage::disk('uploadcare')->get('<uuid>'); // Delete a fileStorage::disk('uploadcare')->delete('<uuid>');
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