nova-field-cloudinary
nova-field-cloudinary copied to clipboard
Support for folders/directory
Originally posted by @Sunil-Kis in https://github.com/Silvanite/nova-field-cloudinary/issues/1#issuecomment-429610494
Interested in this as well - thanks for the package.
That would be nice addition please
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.
Any idea when a patch for this will be available so we can use a folder?
@prestontoor I have taken over maintaining this package. I will look into it.