thomasvantuycom / craft-cloudinary

Cloudinary integration for Craft CMS
MIT License
5 stars 2 forks source link

Invalid Image File #8

Closed valboivin closed 8 months ago

valboivin commented 8 months ago

Hi there!

Seems like some file formats are not supported via uploads in the plugin. For instance, I can easily upload a JSON file directly in our Cloudinary account, but not via our Craft CMS admin panel. I get an "Invalid image file" error.

To fix it on my part, I've added 'resource_type' => 'auto' to the $uploadOptions object of the writeFileFromStream function. (I could probably also add this parameter to the write function.) With this change, I can upload my JSON file without any problem.

I'm wondering if that could be a nice addition or if there's a better way to do this.

Thanks

thomasvantuycom commented 8 months ago

Hi Valerie,

Currently, the plugin exclusively handles image files. I've been actively working on expanding its compatibility to encompass all file types, but that's still in progress. The Cloudinary API poses challenges in how it distinguishes between images, videos, and other assets, making the task of ensuring seamless operation across all file types quite intricate. While extending support to all file types comes with drawbacks such as a noticeable rise in rate-limited API calls, I believe the benefits outweigh the challenges. I aim to complete the implementation within the next two weeks, although I can't make a definitive promise at this time.

thomasvantuycom commented 8 months ago

The issue has been addressed and incorporated into version 1.6.0, which is now available.

valboivin commented 8 months ago

@thomasvantuycom thank you so much, that was quick! 😄

One last thing regarding your changes. I feel like you've forgotten to parse the variable in the creation of the Cloudinary Adapter instance.

The asset uploaded on the Cloudinary account doesn't have the right url: screenshot 2024-01-26 at 2 02 12 PM

On the CloudinaryFS file, I think it should be like this:

return new CloudinaryAdapter($client, App::parseEnv($this->baseFolder), null, $this->dynamicFolders);
thomasvantuycom commented 8 months ago

Well darn, I've made the same mistake for the nth time.

valboivin commented 8 months ago

Happens to the best of us! 😄