enl / flysystem-cloudinary
Cloudinary adapter for Flysystem.
Installs: 90 205
Dependents: 4
Suggesters: 1
Security: 0
Stars: 27
Watchers: 4
Forks: 20
Open Issues: 6
Requires
- php: >=5.4.0
- ext-fileinfo: *
- cloudinary/cloudinary_php: ^1.8.0
- league/flysystem: ^1.0.26
Requires (Dev)
- phpunit/phpunit: ^6
- squizlabs/php_codesniffer: ^2.3.1
This package is auto-updated.
Last update: 2024-12-20 21:17:12 UTC
README
This is a Flysystem adapter for Cloudinary API.
Installation
composer require enl/flysystem-cloudinary '~1.0'
Or just add the following string to require
part of your composer.json
:
{ "require": { "enl/flysystem-cloudinary": "~1.0" } }
Bootstrap
<?php use Enl\Flysystem\Cloudinary\ApiFacade as CloudinaryClient; use Enl\Flysystem\Cloudinary\CloudinaryAdapter; use League\Flysystem\Filesystem; include __DIR__ . '/vendor/autoload.php'; $client = new CloudinaryClient([ 'cloud_name' => 'your-cloudname-here', 'api_key' => 'api-key', 'api_secret' => 'You-know-what-to-do', 'overwrite' => true, // set this to true if you want to overwrite existing files using $filesystem->write(); ]); $adapter = new CloudinaryAdapter($client); // This option disables assert that file is absent before calling `write`. // It is necessary if you want to overwrite files on `write` as Cloudinary does it by default. $filesystem = new Filesystem($adapter, ['disable_asserts' => true]);
Cloudinary features
Please, keep in mind three possible pain-in-asses of Cloudinary:
- It adds automatically file extension to its public_id. In terms of Flysystem, cloudinary's public_id is considered as filename. But if you set public_id as 'test.jpg' Cloudinary will save the file as 'test.jpg.jpg'. In order to work it around, you can use PathConverterInterface.
- It does not support folders creation through the API
- If you want to save your files using folder you should set public_ids like 'test/test.jpg' and allow automated folders creation in your account settings in Cloudinary dashboard.
Good news!
The library supports Cloudinary Transformations!