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