Search code examples
laravelcloudinary

How get cloudinary file url/other properties by public_id?


Saving images under cloudinary( with cloudinary-laravel 1.0) I keep public_id in my database and I want to get url(http or https), size, dimaentainal of this file by public_id

At reading this

/**
 * You can also retrieve a url if you have a public id
 */

$url = Storage::disk('cloudinary')->url($publicId);

at https://github.com/cloudinary-labs/cloudinary-laravel

I got ERROR:

Disk [CLOUDINARY] does not have a configured driver.

  
  

But I save images to cloudinary with storeOnCloudinaryAs method and in my .env I have

CLOUDINARY_URL=cloudinary://NNNNNNNNNNNN:AErjB_-XXXXXXXXX
CLOUDINARY_UPLOAD_PRESET=ml_default

and default file config/cloudinary.php My config/filesystems.php has no any cloudinary parameters and can it be reason of my error?

Also it seems very strange for me that Storage::was used in this case, but I did not find how get file url/other properties by public_id ?

Edited 1: I added line

...
CloudinaryLabs\CloudinaryLaravel\CloudinaryServiceProvider::class,
...

in 'providers' block of ny config/app.php and cleared cach. But still got

"Disk [CLOUDINARY] does not have a configured driver."

error.

applying changes into .env and clearing cache I try to debug from which line error is triggered in file vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php as :

protected function resolve($name)
{
    $config = $this->getConfig($name);

    \Log::info(  varDump($name, ' -1 $name resolve::') ); // IT HAS ‘CLOUDINARY’ value
    if (empty($config['driver'])) {
        throw new InvalidArgumentException("Disk [{$name}] does not have a configured driver.");
    }

But what is source for $config in this file?

config/filesystems.php ? In this file I have no any CLOUDINARY block. maybe I need to add it? But in which format ?

Thanks in advance!


Solution

  • Setting driver to lowercase

    $cloudinaryUrl = Storage::disk(strtolower($imagesUploadSource))
    

    fixed this error.