https://github.com/carlosocarvalho/flysystem-cloudinary
Adapter for theleague php flysystem for Cloudinary
https://github.com/carlosocarvalho/flysystem-cloudinary
flysystem flysystem-adapter flysystem-cloudinary theleague-php-flysystem
Last synced: 3 months ago
JSON representation
Adapter for theleague php flysystem for Cloudinary
- Host: GitHub
- URL: https://github.com/carlosocarvalho/flysystem-cloudinary
- Owner: carlosocarvalho
- Created: 2016-02-02T03:28:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-16T17:42:30.000Z (4 months ago)
- Last Synced: 2025-03-29T12:03:46.595Z (3 months ago)
- Topics: flysystem, flysystem-adapter, flysystem-cloudinary, theleague-php-flysystem
- Language: PHP
- Size: 384 KB
- Stars: 22
- Watchers: 1
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flysystem-cloudinary v3
Cloudinary adapter for The PHP League Flysystem v3[](https://app.codacy.com/app/carlosocarvalho-git/flysystem-cloudinary?utm_source=github.com&utm_medium=referral&utm_content=carlosocarvalho/flysystem-cloudinary&utm_campaign=Badge_Grade_Dashboard)
[](https://twitter.com/carlosocarvalho)
[](//packagist.org/packages/carlosocarvalho/flysystem-cloudinary) [](https://packagist.org/packages/carlosocarvalho/flysystem-cloudinary) [](https://packagist.org/packages/carlosocarvalho/flysystem-cloudinary)
[](//packagist.org/packages/carlosocarvalho/flysystem-cloudinary)
[](//packagist.org/packages/carlosocarvalho/flysystem-cloudinary)
[](//packagist.org/packages/carlosocarvalho/flysystem-cloudinary)
[](//packagist.org/packages/carlosocarvalho/flysystem-cloudinary)## Install
```bash
composer require carlosocarvalho/flysystem-cloudinary
```## Configuration
You can configure the package in two different ways.
### Using CLOUDINARY_URL
You can configure the library using the environment variable ```CLOUDINARY_URL```. Whe using ```CLOUDINARY_URL``` you have access to the underlying Cloudinary SDK without instantiating the adapter or explicit instantiating the Cloudinary SDK.You can read more in their documentation https://cloudinary.com/documentation/php_integration#setting_the_cloudinary_url_environment_variable
```php
use CarlosOCarvalho\Flysystem\Cloudinary\CloudinaryAdapter;
use League\Flysystem\Filesystem;$adapter = new CloudinaryAdapter();
$filesystem = new Filesystem( $adapter );```
### Manual configuration
```php
use CarlosOCarvalho\Flysystem\Cloudinary\CloudinaryAdapter;
use League\Flysystem\Filesystem;$config = [
'api_key' => ':key',
'api_secret' => ':secret',
'cloud_name' => ':name',
];$adapter = new CloudinaryAdapter($config);
$filesystem = new Filesystem( $adapter );```
## Example
### List contents and others actions use Filesystem api
```php
#Options use file type resource
$filesystem->listContents()
```
### Add Resource Type list in container `image`,`video`, `raw`
```php
CloudinaryAdapter::$resourceType = \Cloudinary\Asset\AssetType::IMAGE;
$filesystem->listContents()```
### Add content list type in container 'upload', 'private', 'authenticated', 'fetch', 'facebook', 'twitter', 'gravatar', 'youtube', 'hulu', 'vimeo', 'animoto', 'worldstarhiphop', 'dailymotion', 'list'
```php
CloudinaryAdapter::$listContentsType = \Cloudinary\Asset\DeliveryType::UPLOAD;
$filesystem->listContents()
```### For use in laravel
To use in Laravel register you must register the driver. Learn how to register a custom filesystem in the Laravel Documentation.
```php
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
use CarlosOCarvalho\Flysystem\Cloudinary\CloudinaryAdapter;...
Storage::extend('cloudinary', function ($app, $config) {
if(!empty(env('CLOUDINARY_URL'))){
$adapter = new CloudinaryAdapter();
}else{
$adapter = new CloudinaryAdapter($config);
}return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$config
);
});```