yoelpc4 / laravel-cloudinary
Laravel Cloudinary filesystem cloud driver.
Installs: 28 157
Dependents: 0
Suggesters: 0
Security: 0
Stars: 30
Watchers: 4
Forks: 10
Open Issues: 1
Requires
- php: >=8.1
- cloudinary/cloudinary_php: ^2.9.0
- illuminate/contracts: 10.*|^11.0
- illuminate/filesystem: 10.*|^11.0
- illuminate/http: 10.*|^11.0
- illuminate/support: 10.*|^11.0
- league/flysystem: ^3.8.0
Requires (Dev)
- orchestra/testbench: 8.*|^9.0
- phpunit/phpunit: 10.*
This package is auto-updated.
Last update: 2025-01-18 20:03:11 UTC
README
Laravel Cloudinary filesystem driver.
Requirement
Laravel Version Compatibilities
Install
Requires this package with composer via command:
composer require yoelpc4/laravel-cloudinary
Environment Variable
Register your Cloudinary account details here. Then add these lines to your .env.
FILESYSTEM_DISK=cloudinary CLOUDINARY_API_KEY= CLOUDINARY_API_SECRET= CLOUDINARY_CLOUD_NAME= CLOUDINARY_SECURE=true
Filesystem Configuration
Register cloudinary driver configuration in config/filesystems.php
at disks section as follows
'cloudinary' => [ 'driver' => 'cloudinary', 'api_key' => env('CLOUDINARY_API_KEY'), 'api_secret' => env('CLOUDINARY_API_SECRET'), 'cloud_name' => env('CLOUDINARY_CLOUD_NAME'), 'secure' => env('CLOUDINARY_SECURE', true), 'resource_types' => [ 'image' => [ 'png', 'jpeg', 'jpg', ], 'video' => [ 'mp4', 'avi', 'mp3', 'flac', ], 'raw' => [ 'pdf', 'xlsx', 'csv', 'txt', ], ], ],
The secure option is applied when generating url from storage, when secure = true
will use https
otherwise secure = false
will use http
as protocol.
The resource_types option is applied when generating resource type & public id whenever we call storage method such as
write, writeStream, url, has, etc. Registers the appropriate file extensions according to cloudinary resource type e.g:
png in image, mp4 in video, xlsx in raw, for audio files registers in video. The default resource type is image
,
visit image upload api reference for more information.
Tips
To use pre-defined filename as public ID when uploading to cloudinary, you need to tweak some configuration
in Settings -> Upload -> Upload presets
as follows:
-
Click edit button on signed mode preset, initial preset is
ml_default
you can update it. -
Turn on
Use filename or externally defined public ID
to using the pre-defined filename instead of random characters. -
Turn off
Unique filename
to prevent cloudinary from adding random characters at the end of filename. -
Click
Save
and you're good to go.
License
The Laravel Cloudinary is open-sourced software licensed under the MIT license.