IO-998 Resolve media rename issues for non images.

This commit is contained in:
Patrick Fic
2021-05-27 08:49:43 -07:00
parent 48ecfe0d98
commit 1b0e37be45
2 changed files with 15 additions and 1 deletions

View File

@@ -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";

View File

@@ -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";
}