Capture Photo Info & Change Env Dynamically.

This commit is contained in:
Patrick Fic
2021-05-20 09:36:16 -07:00
parent 48514e72a5
commit 5647a52ef0
10 changed files with 62 additions and 87 deletions

View File

@@ -3,6 +3,8 @@ import env from "../env";
import { client } from "../graphql/client";
import { INSERT_NEW_DOCUMENT } from "../graphql/documents.queries";
import { axiosAuthInterceptorId } from "./CleanAxios";
import * as MediaLibrary from "expo-media-library";
//Context: currentUserEmail, bodyshop, jobid, invoiceid
//Required to prevent headers from getting set and rejected from Cloudinary.
@@ -45,15 +47,8 @@ export const uploadToCloudinary = async (
onProgress,
context
) => {
const {
bodyshop,
jobId,
billId,
uploaded_by,
callback,
tagsArray,
photo,
} = context;
const { bodyshop, jobId, billId, uploaded_by, callback, tagsArray, photo } =
context;
//Set variables for getting the signed URL.
let timestamp = Math.floor(Date.now() / 1000);
@@ -139,7 +134,12 @@ export const uploadToCloudinary = async (
if (onError) onError(cloudinaryUploadResponse.statusText);
return { success: false, error: cloudinaryUploadResponse.statusText };
}
console.log("mediaId", mediaId);
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
console.log(
"🚀 ~ file: document-upload.utility.js ~ line 140 ~ imageData",
imageData.creationTime
);
//Insert the document with the matching key.
const documentInsert = await client.mutate({
mutation: INSERT_NEW_DOCUMENT,
@@ -154,6 +154,9 @@ export const uploadToCloudinary = async (
extension: extension,
bodyshopid: bodyshop.id,
size: cloudinaryUploadResponse.data.bytes || file.size,
...(imageData.creationTime
? { takenat: new Date(imageData.creationTime) }
: {}),
},
],
},