IO-998 Resolve media rename issues for non images.
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user