We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi!
I have a problem with deleting images.
When I add a file, your plugin does add all custom sizes with a .map of all sizes.
I can find all the files on S3 with all the different sizes.
On the other hand, when I delete an image from payload, it does delete the original file, but does not delete all custom sized files.
When I take a closer look at the plugin, the 'deleteHook ()' hook doesn't map the different file sizes but only the original file.
Have you noticed this problem? Is this normal or is there a way to map the sizes object like on the 'uploadHook ()' hook.
Here is the difference between the two hooks, we better understand their behavior:
uploadHook
const uploadHook = (adapter: AdapterInterface) => { const beforeChange: CollectionBeforeChangeHook = async (args) => { const { req, data } = args if (req?.files?.file) { let uploadedFile: UploadedFile if (Array.isArray(req.files.file)) { uploadedFile = req.files.file[0] } else { uploadedFile = req.files.file } const resizedBuffers = req.payloadUploadSizes ? Object.keys(req.payloadUploadSizes) .map(uploadSize => { const name = data?.sizes?.[uploadSize]?.filename const mimetype = uploadedFile?.mimetype const buffer = req?.payloadUploadSizes?.[uploadSize] if (name && mimetype && buffer) { return adapter.upload({ name, data: buffer, mimetype: mimetype }) } }) .filter(buffer => typeof buffer !== 'undefined') : [] await Promise.all([adapter.upload(uploadedFile), ...resizedBuffers]) } } return beforeChange } export default uploadHook
deleteHook
export const deleteHook = (adapter: AdapterInterface) => { const afterDelete: CollectionAfterDeleteHook = async (args) => { const { doc } = args await adapter.delete(doc.filename) } return afterDelete }
Thank's in advance for your answer!
And sorry for my bad english, i'm a french developer and i don't speak English very well....
The text was updated successfully, but these errors were encountered:
Hi there. Sorry it's taken so long to get back to you on this.
Yes it seems as though you're correct I do need to loop over the sizes. Good catch!
I'll address this later this week.
Sorry, something went wrong.
richardvanbergen
No branches or pull requests
Hi!
I have a problem with deleting images.
When I add a file, your plugin does add all custom sizes with a .map of all sizes.
I can find all the files on S3 with all the different sizes.
On the other hand, when I delete an image from payload, it does delete the original file, but does not delete all custom sized files.
When I take a closer look at the plugin, the 'deleteHook ()' hook doesn't map the different file sizes but only the original file.
Have you noticed this problem? Is this normal or is there a way to map the sizes object like on the 'uploadHook ()' hook.
Here is the difference between the two hooks, we better understand their behavior:
uploadHook
deleteHook
Thank's in advance for your answer!
And sorry for my bad english, i'm a french developer and i don't speak English very well....
The text was updated successfully, but these errors were encountered: