nova-field-cloudinary icon indicating copy to clipboard operation
nova-field-cloudinary copied to clipboard

Support for folders/directory

Open m2de opened this issue 6 years ago • 5 comments

Originally posted by @Sunil-Kis in https://github.com/Silvanite/nova-field-cloudinary/issues/1#issuecomment-429610494

m2de avatar Nov 09 '18 08:11 m2de

Interested in this as well - thanks for the package.

reganjohnson avatar Dec 21 '18 17:12 reganjohnson

That would be nice addition please

aurawindsurfing avatar May 16 '19 10:05 aurawindsurfing

I've added support for folders in this fork: https://github.com/eithed/nova-field-cloudinary

Then, all that is needed is definition of Field class to write into a specific folder on Cloudinary (in my case the folder path is defined via .env). This can be defined in the project itself:

<?php

namespace App\Nova\Fields;

use Silvanite\NovaFieldCloudinary\Fields\CloudinaryImage;

class Image extends CloudinaryImage
{
    public function __construct($name, $attribute = null, $disk = 'cloudinary', $storageCallback = null)
    {
        $this->storagePath = '/'.config('filesystems.disks.cloudinary.cloud_folder');

        parent::__construct($name, $attribute, $disk, $storageCallback);
    }
}

Probably one could go and extend CloudinaryImage class to have a setOptions method where options could be passed to Cloudinary\Uploader (so, one could affect other Cloudinary options), but I failed to find how to access the field in the CloudinaryAdapter::writeStream where the upload takes place and League\Flysystem\Filesystem doesn't strike me as easily extendable to support this (maybe through League\Flysystem\Config). But, as I needed just folders support, this does the trick.

eithed avatar Jun 12 '19 17:06 eithed

Any idea when a patch for this will be available so we can use a folder?

prestontoor avatar Jan 06 '21 11:01 prestontoor

@prestontoor I have taken over maintaining this package. I will look into it.

lukebouch avatar Aug 15 '22 13:08 lukebouch