diff --git a/client/src/components/documents-upload/documents-upload.utility.js b/client/src/components/documents-upload/documents-upload.utility.js index 8812aefd3..5856d985e 100644 --- a/client/src/components/documents-upload/documents-upload.utility.js +++ b/client/src/components/documents-upload/documents-upload.utility.js @@ -176,6 +176,7 @@ export const uploadToCloudinary = async ( } }; +//Also needs to be updated in media JS and mobile app. export function DetermineFileType(filetype) { if (!filetype) return "auto"; else if (filetype.startsWith("image")) return "image"; diff --git a/server/media/media.js b/server/media/media.js index 9aa60663e..e02beeac5 100644 --- a/server/media/media.js +++ b/server/media/media.js @@ -40,7 +40,9 @@ exports.renameKeys = async (req, res) => { try { const res = { id: d.id, - ...(await cloudinary.uploader.rename(d.from, d.to)), + ...(await cloudinary.uploader.rename(d.from, d.to, { + resource_type: DetermineFileType(d.type), + })), }; return res; } catch (error) { @@ -56,3 +58,14 @@ exports.renameKeys = async (req, res) => { res.send(result); }; + +//Also needs to be updated in upload utility and mobile app. +function DetermineFileType(filetype) { + if (!filetype) return "auto"; + else if (filetype.startsWith("image")) return "image"; + else if (filetype.startsWith("video")) return "video"; + else if (filetype.startsWith("application/pdf")) return "image"; + else if (filetype.startsWith("application")) return "raw"; + + return "auto"; +}