Added file extesions for documents IO-525

This commit is contained in:
Patrick Fic
2021-02-04 15:21:04 -08:00
parent 6e33b5fd6b
commit c3d1de592a
11 changed files with 212 additions and 27 deletions

View File

@@ -20,8 +20,10 @@ export const handleUpload = (ev, context) => {
const { bodyshop, jobId } = context;
let key = `${bodyshop.id}/${jobId}/${ev.file.name.replace(/\.[^/.]+$/, "")}`;
let extension = ev.file.name.split(".").pop();
uploadToCloudinary(
key,
extension,
ev.file.type,
ev.file,
onError,
@@ -33,6 +35,7 @@ export const handleUpload = (ev, context) => {
export const uploadToCloudinary = async (
key,
extension,
fileType,
file,
onError,
@@ -94,7 +97,7 @@ export const uploadToCloudinary = async (
formData.append("signature", signature);
const cloudinaryUploadResponse = await cleanAxios.post(
`${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${DetermineFileType(
`${process.env.REACT_APP_CLOUDINARY_ENDPOINT_API}/${DetermineFileType(
fileType
)}/upload`,
formData,
@@ -129,6 +132,7 @@ export const uploadToCloudinary = async (
key: key,
billid: billId,
type: fileType,
extension: extension,
},
],
},
@@ -164,6 +168,7 @@ export function DetermineFileType(filetype) {
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";
}