when setting up hooks in my list to delete a file from Cloudinary after the record has been deleted like this...
keystone.createList('post', {
fields: {
text: { type: Text, required: true },
media: {
type: File,
adapter: fileAdapter,
hooks: {
beforeChange: async ({ existingItem }) => {
if (existingItem && existingItem.media) {
await fileAdapter.delete(existingItem.media);
}
},
},
},
poster: { type: Relationship, ref: 'socialProfile', many: false }
},
hooks: {
afterDelete: async ({ existingItem }) => {
if (existingItem.media) {
await fileAdapter.delete(existingItem.media);
}
},
},
});
I get an error from GraphQl stating that an api_key is required.

It appears that the API credentials passed to CloudinaryAdapter are not passed to the delete function, as they are in the upload function. The options are just defaulted to an empty object:
A simple workaround would be to additionally pass the API creds directly to the delete function, like so:
await fileAdapter.delete(existingItem.image, {
cloud_name: CLOUD_NAME,
api_key: API_KEY,
api_secret: API_SECRET,
})
Hmmm, we should be able to pass these through to the delete function when the adapter is initialised. This looks like a reasonably small issue for someone familiar with the cloudinary adapter. PRs welcome, otherwise it will go on my backlog :)
Most helpful comment
It appears that the API credentials passed to
CloudinaryAdapterare not passed to thedeletefunction, as they are in the upload function. The options are just defaulted to an empty object:https://github.com/keystonejs/keystone/blob/070519dbec289b759759343d084bc5d2de9d4b37/packages/file-adapters/lib/cloudinary.js#L53-L67
A simple workaround would be to additionally pass the API creds directly to the delete function, like so: