IO-750 Resolve overwriting images on iOS Upload

This commit is contained in:
Patrick Fic
2021-03-09 15:36:35 -08:00
parent 5ef9903a6d
commit b45ed8ad17
6 changed files with 143 additions and 116 deletions

View File

@@ -10,13 +10,13 @@ var cleanAxios = axios.create();
cleanAxios.interceptors.request.eject(axiosAuthInterceptorId);
export const handleUpload = async (ev, context) => {
const { onError, onSuccess, onProgress } = ev;
const { uri, filename, onError, onSuccess, onProgress } = ev;
const { bodyshop, jobId } = context;
const newFile = await (await fetch(ev.uri)).blob();
const newFile = await (await fetch(uri)).blob();
let extension = ev.uri.split(".").pop();
let key = `${bodyshop.id}/${jobId}/${newFile.data.name.replace(
let key = `${bodyshop.id}/${jobId}/${(filename || newFile.data.name).replace(
/\.[^/.]+$/,
""
)}`;
@@ -123,7 +123,7 @@ export const uploadToCloudinary = async (
);
// console.log("Cloudinary Upload Response", cloudinaryUploadResponse.data);
} catch (error) {
console.log("CLOUDINARY error", error, cloudinaryUploadResponse);
console.log("CLOUDINARY error", error.response, cloudinaryUploadResponse);
return { success: false, error: error };
}