Problem/Motivation
Cloudinary's stream wrapper does not support the move operation. I belive this is caused by the fact that \Drupal\cloudinary_stream_wrapper\StreamWrapper\CloudinaryStreamWrapper::stat() does not properly report that the directory/folder exists when drupal prepares the directory in \Drupal\Core\File\FileSystem::move().
I believe the root cause of this issue is that \Drupal\cloudinary_stream_wrapper\StreamWrapper\CloudinaryStreamWrapper::loadResource() does not load directory resources as it should.
Steps to reproduce
Try to create a cloudinary image media entity via Drupal core's JSON:API, and the second request will throw the following error:
The specified file 'temporary://filexkpCkd' could not be copied because the destination directory 'cloudinary://2022-12' is not properly configured. This may be caused by a problem with file or directory permissions.
Example:
# USING JETBRIANS HTTP CLIENT ### Step 1: Upload the image file to drupal with json api. POST https://example.com /jsonapi /media /cloudinary_image /field_media_cloudinary_image Authorization: Basic username password Content-Type: application/octet-stream Accept: application/vnd.api+json Content-Disposition: file; filename="ReplaceMe.png" < /Users/christophersnyder/LoremIpsum/ReplaceMe.png ### Step 2: Create the image media entity with the json api, using the file id/uuid from the previous step's response. POST https://example.com /jsonapi /media /cloudinary_image Authorization: Basic username password Accept: application/vnd.api+json Content-Type: application/vnd.api+json { "data": { "type": "media--cloudinary_image", "attributes": { "name": "REPLACE ME" }, "relationships": { "field_media_cloudinary_image": { "data": { "type": "file--file", "id": "c777c1c4-c991-4b82-b60b-018fe2ddc638", "meta": { "alt": "alt", "title": "title" } } } } } }
Proposed resolution
Fix \Drupal\cloudinary_stream_wrapper\StreamWrapper\CloudinaryStreamWrapper::loadResource() so it can load file/folder resources from cloudinary.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | cloudinary-stream_wrapper_move-3326946-3.patch | 885 bytes | chrissnyder |
Issue fork cloudinary-3326946
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
chrissnyderThis is my initial attempt at correcting the issue. This change has resolved the issue, allowing Cloudinary image media items to be created using JSON API
Comment #4
chrissnyderComment #5
rohit.rawat619 commentedComment #6
rohit.rawat619 commentedComment #7
chrissnyder@RohitRawat676 I don't see how the patch you uploaded relates to this issue. I think it was intended for #2942513: Cloudinary crop image effect.