Capture Photo Info & Change Env Dynamically.
This commit is contained in:
@@ -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) }
|
||||
: {}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user