1.3.6-5 Resolve uploads for cloudinary.
This commit is contained in:
6
app.json
6
app.json
@@ -4,19 +4,19 @@
|
||||
"slug": "imexmobile",
|
||||
"version": "1.3.6",
|
||||
"extra": {
|
||||
"expover": "4"
|
||||
"expover": "5"
|
||||
},
|
||||
"orientation": "default",
|
||||
"icon": "./assets/logo192noa.png",
|
||||
"ios": {
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "com.imex.imexmobile",
|
||||
"buildNumber": "4",
|
||||
"buildNumber": "5",
|
||||
"googleServicesFile": "./GoogleService-Info.plist"
|
||||
},
|
||||
"android": {
|
||||
"package": "com.imex.imexmobile",
|
||||
"versionCode": 1100009,
|
||||
"versionCode": 1100010,
|
||||
"googleServicesFile": "./google-services.json"
|
||||
},
|
||||
"splash": {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
import { DateTime } from "luxon";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
@@ -50,8 +49,6 @@ export function UploadProgress({
|
||||
speed: 0,
|
||||
});
|
||||
|
||||
let filesToDelete = [];
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -118,22 +115,12 @@ export function UploadProgress({
|
||||
|
||||
if (deleteAfterUpload) {
|
||||
try {
|
||||
const a = await MediaLibrary.getAssetsAsync();
|
||||
|
||||
const res = await Promise.all(
|
||||
filesToDelete.map((f) => {
|
||||
return MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId);
|
||||
})
|
||||
);
|
||||
|
||||
const deleteResult = await MediaLibrary.deleteAssetsAsync(
|
||||
filesToDelete.map((f) => f.id)
|
||||
);
|
||||
await MediaLibrary.deleteAssetsAsync(data);
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
}
|
||||
}
|
||||
filesToDelete = [];
|
||||
|
||||
setProgress({
|
||||
loading: false,
|
||||
speed: 0,
|
||||
@@ -143,7 +130,6 @@ export function UploadProgress({
|
||||
forceRerender();
|
||||
};
|
||||
|
||||
console.log(progress);
|
||||
return (
|
||||
<Modal
|
||||
visible={progress.uploadInProgress}
|
||||
@@ -180,7 +166,7 @@ export function UploadProgress({
|
||||
)}/sec`}</Text>
|
||||
<Text
|
||||
style={{ alignSelf: "center", marginTop: 16 }}
|
||||
>{`Total Uploaded ${formatBytes(progress.loaded)}/sec`}</Text>
|
||||
>{`Total Uploaded ${formatBytes(progress.loaded)}`}</Text>
|
||||
<Text style={{ alignSelf: "center", marginTop: 16 }}>{`Duration ${(
|
||||
(new Date() - progress.start) /
|
||||
1000
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createStackNavigator } from "@react-navigation/stack";
|
||||
import i18n from "i18next";
|
||||
import React, { useEffect } from "react";
|
||||
import { Button } from "react-native-paper";
|
||||
import { SafeAreaView } from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function ScreenSettingsComponent() {
|
||||
|
||||
<Text>Release Channel {Updates.releaseChannel}</Text>
|
||||
<SignOutButton />
|
||||
<Button title="Purge State" onPress={() => purgeStoredState()} />
|
||||
{/* <Button title="Purge State" onPress={() => purgeStoredState()} /> */}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export function SignOutButton({ signOutStart }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Button
|
||||
style={{ margin: 8 }}
|
||||
onPress={() => signOutStart()}
|
||||
title={t("general.actions.signout")}
|
||||
/>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { INSERT_NEW_DOCUMENT } from "../graphql/documents.queries";
|
||||
import { axiosAuthInterceptorId } from "./CleanAxios";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
import { gql } from "@apollo/client";
|
||||
import mime from "mime";
|
||||
|
||||
//Context: currentUserEmail, bodyshop, jobid, invoiceid
|
||||
|
||||
@@ -18,9 +17,9 @@ export const handleUpload = async (ev, context) => {
|
||||
const { bodyshop, jobId } = context;
|
||||
|
||||
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
|
||||
// const newFile = await (await fetch(imageData.localUri)).blob();
|
||||
let extension = imageData.filename.split(".").pop();
|
||||
let key = `${bodyshop.id}/${jobId}/${filename.replace(
|
||||
const newFile = await (await fetch(imageData.localUri)).blob();
|
||||
let extension = imageData.localUri.split(".").pop();
|
||||
let key = `${bodyshop.id}/${jobId}/${(filename || newFile.data.name).replace(
|
||||
/\.[^/.]+$/,
|
||||
""
|
||||
)}-${new Date().getTime()}`;
|
||||
@@ -30,8 +29,8 @@ export const handleUpload = async (ev, context) => {
|
||||
mediaId,
|
||||
imageData,
|
||||
extension,
|
||||
mime.getType(imageData.uri),
|
||||
//newFile,
|
||||
newFile.type,
|
||||
newFile,
|
||||
onError,
|
||||
onSuccess,
|
||||
onProgress,
|
||||
@@ -46,7 +45,7 @@ export const uploadToCloudinary = async (
|
||||
imageData,
|
||||
extension,
|
||||
fileType,
|
||||
//file,
|
||||
file,
|
||||
onError,
|
||||
onSuccess,
|
||||
onProgress,
|
||||
@@ -108,7 +107,7 @@ export const uploadToCloudinary = async (
|
||||
formData.append("file", {
|
||||
uri: imageData.localUri,
|
||||
type: fileType,
|
||||
name: imageData.filename,
|
||||
name: file.data.name,
|
||||
});
|
||||
formData.append("upload_preset", upload_preset);
|
||||
formData.append("api_key", env.REACT_APP_CLOUDINARY_API_KEY);
|
||||
@@ -182,7 +181,7 @@ export const uploadToCloudinary = async (
|
||||
type: fileType,
|
||||
extension: extension,
|
||||
bodyshopid: bodyshop.id,
|
||||
size: cloudinaryUploadResponse.data.bytes, //|| file.size,
|
||||
size: cloudinaryUploadResponse.data.bytes || file.size,
|
||||
...(imageData.creationTime
|
||||
? { takenat: new Date(imageData.creationTime) }
|
||||
: {}),
|
||||
|
||||
Reference in New Issue
Block a user