IOS-7 Added takenat to documents and uploads.

This commit is contained in:
Patrick Fic
2021-05-19 17:52:24 -07:00
parent a7878243ee
commit fddf75b40b
11 changed files with 221 additions and 4 deletions

View File

@@ -5,6 +5,8 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
import { INSERT_NEW_DOCUMENT } from "../../graphql/documents.queries";
import { axiosAuthInterceptorId } from "../../utils/CleanAxios";
import client from "../../utils/GraphQLClient";
import exifr from "exifr";
//Context: currentUserEmail, bodyshop, jobid, invoiceid
//Required to prevent headers from getting set and rejected from Cloudinary.
@@ -85,6 +87,7 @@ export const uploadToCloudinary = async (
if (!!onProgress) onProgress({ percent: (e.loaded / e.total) * 100 });
},
};
const formData = new FormData();
formData.append("file", file);
@@ -122,6 +125,12 @@ export const uploadToCloudinary = async (
}
//Insert the document with the matching key.
let takenat;
if (fileType.includes("image")) {
const exif = await exifr.parse(file);
console.log(`exif`, exif);
takenat = exif && exif.DateTimeOriginal;
}
const documentInsert = await client.mutate({
mutation: INSERT_NEW_DOCUMENT,
variables: {
@@ -135,6 +144,7 @@ export const uploadToCloudinary = async (
extension: extension,
bodyshopid: bodyshop.id,
size: cloudinaryUploadResponse.data.bytes || file.size,
takenat,
},
],
},