1.3.6(1) Resolved local upload issues due to form type.
This commit is contained in:
8
app.json
8
app.json
@@ -2,21 +2,21 @@
|
|||||||
"expo": {
|
"expo": {
|
||||||
"name": "ImEX Mobile",
|
"name": "ImEX Mobile",
|
||||||
"slug": "imexmobile",
|
"slug": "imexmobile",
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"extra": {
|
"extra": {
|
||||||
"expover": "2"
|
"expover": "1"
|
||||||
},
|
},
|
||||||
"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": "2",
|
"buildNumber": "1",
|
||||||
"googleServicesFile": "./GoogleService-Info.plist"
|
"googleServicesFile": "./GoogleService-Info.plist"
|
||||||
},
|
},
|
||||||
"android": {
|
"android": {
|
||||||
"package": "com.imex.imexmobile",
|
"package": "com.imex.imexmobile",
|
||||||
"versionCode": 1100002,
|
"versionCode": 1100006,
|
||||||
"googleServicesFile": "./google-services.json"
|
"googleServicesFile": "./google-services.json"
|
||||||
},
|
},
|
||||||
"splash": {
|
"splash": {
|
||||||
|
|||||||
Binary file not shown.
BIN
build-1652553531738.ipa
Normal file
BIN
build-1652553531738.ipa
Normal file
Binary file not shown.
@@ -136,6 +136,10 @@ export function UploadProgress({
|
|||||||
|
|
||||||
//Sequentially await the proms.
|
//Sequentially await the proms.
|
||||||
|
|
||||||
|
// for (const file of data) {
|
||||||
|
// await CreateUploadProm(file);
|
||||||
|
// }
|
||||||
|
|
||||||
for (var i = 0; i < data.length + 4; i = i + 4) {
|
for (var i = 0; i < data.length + 4; i = i + 4) {
|
||||||
let proms = [];
|
let proms = [];
|
||||||
if (data[i]) {
|
if (data[i]) {
|
||||||
@@ -157,8 +161,7 @@ export function UploadProgress({
|
|||||||
if (deleteAfterUpload) {
|
if (deleteAfterUpload) {
|
||||||
try {
|
try {
|
||||||
const a = await MediaLibrary.getAssetsAsync();
|
const a = await MediaLibrary.getAssetsAsync();
|
||||||
console.log("assets", a);
|
|
||||||
console.log("filestodelete", filesToDelete);
|
|
||||||
const res = await Promise.all(
|
const res = await Promise.all(
|
||||||
filesToDelete.map((f) => {
|
filesToDelete.map((f) => {
|
||||||
return MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId);
|
return MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId);
|
||||||
|
|||||||
@@ -184,13 +184,6 @@ export function UploadProgress({
|
|||||||
const deleteResult = await MediaLibrary.deleteAssetsAsync(
|
const deleteResult = await MediaLibrary.deleteAssetsAsync(
|
||||||
filesToDelete
|
filesToDelete
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("res", res);
|
|
||||||
console.log(
|
|
||||||
"🚀 ~ file: upload-progress.component.jsx ~ line 177 ~ deleteResult",
|
|
||||||
filesToDelete,
|
|
||||||
deleteResult
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Unable to delete picture.", error);
|
console.log("Unable to delete picture.", error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
"build:production": "eas build --profile production",
|
"build:production": "eas build --profile production",
|
||||||
"build:test": "eas build --profile test",
|
"build:test": "eas build --profile test",
|
||||||
"build:test:local:ios": "eas build --profile test --platform ios --local",
|
"build:test:local:ios": "eas build --profile test --platform ios --local",
|
||||||
"build:test:local:android": "eas build --profile test --platform android --local"
|
"build:test:local:android": "eas build --profile test --platform android --local",
|
||||||
|
"build:production:local:ios": "eas build --profile production --platform ios --local",
|
||||||
|
"build:production:local:android": "eas build --profile production --platform android --local"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.7.0-alpha.3",
|
"@apollo/client": "^3.7.0-alpha.3",
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
"@react-navigation/drawer": "^6.3.1",
|
"@react-navigation/drawer": "^6.3.1",
|
||||||
"@react-navigation/native": "^6.0.8",
|
"@react-navigation/native": "^6.0.8",
|
||||||
"@react-navigation/stack": "^6.1.1",
|
"@react-navigation/stack": "^6.1.1",
|
||||||
"axios": "^0.21.0",
|
"axios": "^0.27.2",
|
||||||
"cloudinary-core": "^2.12.3",
|
"cloudinary-core": "^2.12.3",
|
||||||
"dinero.js": "^1.9.1",
|
"dinero.js": "^1.9.1",
|
||||||
"expo": "^45.0.0",
|
"expo": "^45.0.0",
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
"intl": "^1.2.5",
|
"intl": "^1.2.5",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"luxon": "^2.3.1",
|
"luxon": "^2.3.1",
|
||||||
|
"mime": "^3.0.0",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"normalize-url": "^7.0.3",
|
"normalize-url": "^7.0.3",
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
|
|||||||
@@ -109,12 +109,13 @@ export function* signInSuccessSaga({ payload }) {
|
|||||||
|
|
||||||
const shop = yield client.query({ query: QUERY_BODYSHOP });
|
const shop = yield client.query({ query: QUERY_BODYSHOP });
|
||||||
logImEXEvent("imexmobile_sign_in_success", payload);
|
logImEXEvent("imexmobile_sign_in_success", payload);
|
||||||
yield put(
|
yield put(setBodyshop(shop.data.bodyshops[0]));
|
||||||
setBodyshop({
|
// yield put(
|
||||||
...shop.data.bodyshops[0],
|
// setBodyshop({
|
||||||
localmediaserverhttp: `http://192.168.1.235:8000`,
|
// ...shop.data.bodyshops[0],
|
||||||
})
|
// localmediaserverhttp: `http://192.168.0.142:8000`,
|
||||||
);
|
// })
|
||||||
|
// );
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("UH-OH. Couldn't get shop details.", error);
|
console.log("UH-OH. Couldn't get shop details.", error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,100 +1,132 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { store } from "../redux/store";
|
import { store } from "../redux/store";
|
||||||
|
import mime from "mime";
|
||||||
import * as MediaLibrary from "expo-media-library";
|
import * as MediaLibrary from "expo-media-library";
|
||||||
import * as ImageManipulator from "expo-image-manipulator";
|
import * as ImageManipulator from "expo-image-manipulator";
|
||||||
|
|
||||||
|
axios.interceptors.request.use(
|
||||||
|
function (config) {
|
||||||
|
config.metadata = { startTime: new Date() };
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
axios.interceptors.response.use(
|
||||||
|
function (response) {
|
||||||
|
response.config.metadata.endTime = new Date();
|
||||||
|
response.duration =
|
||||||
|
response.config.metadata.endTime - response.config.metadata.startTime;
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
error.config.metadata.endTime = new Date();
|
||||||
|
error.duration =
|
||||||
|
error.config.metadata.endTime - error.config.metadata.startTime;
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const handleLocalUpload = async ({ ev, context }) => {
|
export const handleLocalUpload = async ({ ev, context }) => {
|
||||||
const { onError, onSuccess, onProgress, filename, mediaId } = ev;
|
const { onError, onSuccess, onProgress, filename, mediaId } = ev;
|
||||||
const { jobid, invoice_number, vendorid, callbackAfterUpload } = context;
|
const { jobid, invoice_number, vendorid, callbackAfterUpload } = context;
|
||||||
const bodyshop = store.getState().user.bodyshop;
|
const bodyshop = store.getState().user.bodyshop;
|
||||||
var options = {
|
|
||||||
headers: {
|
|
||||||
"X-Requested-With": "XMLHttpRequest",
|
|
||||||
ims_token: bodyshop.localmediatoken,
|
|
||||||
},
|
|
||||||
onUploadProgress: (e) => {
|
|
||||||
if (onProgress) onProgress({ percent: (e.loaded / e.total) * 100 });
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
|
|
||||||
formData.append("jobid", jobid);
|
|
||||||
if (invoice_number) {
|
|
||||||
formData.append("invoice_number", invoice_number);
|
|
||||||
formData.append("vendorid", vendorid);
|
|
||||||
}
|
|
||||||
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
|
|
||||||
|
|
||||||
let newFile;
|
|
||||||
try {
|
try {
|
||||||
newFile = await (await fetch(imageData.localUri || imageData.uri)).blob();
|
var options = {
|
||||||
} catch (error) {
|
headers: {
|
||||||
console.log("blobbing error", error, imageData.localUri || imageData.uri);
|
"Content-Type": "multipart/form-data",
|
||||||
}
|
ims_token: bodyshop.localmediatoken,
|
||||||
|
},
|
||||||
let thumb;
|
onUploadProgress: (e) => {
|
||||||
let fileData = {
|
if (onProgress) onProgress({ percent: (e.loaded / e.total) * 100 });
|
||||||
uri: null,
|
},
|
||||||
type: null,
|
|
||||||
name: null,
|
|
||||||
};
|
|
||||||
if (newFile.type === "image/heic") {
|
|
||||||
try {
|
|
||||||
thumb = await ImageManipulator.manipulateAsync(imageData.uri, [], {
|
|
||||||
format: "jpeg",
|
|
||||||
base64: true,
|
|
||||||
compress: 0.75,
|
|
||||||
});
|
|
||||||
const name = newFile.data.name.split(".");
|
|
||||||
name.pop();
|
|
||||||
fileData = {
|
|
||||||
uri: thumb.uri,
|
|
||||||
type: newFile.type,
|
|
||||||
name: name.join("") + ".jpeg",
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
onError && onError(error.message);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fileData = {
|
|
||||||
uri: imageData.localUri || imageData.uri,
|
|
||||||
type: newFile.type,
|
|
||||||
name: filename,
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
formData.append("file", fileData);
|
const formData = new FormData();
|
||||||
|
|
||||||
try {
|
formData.append("jobid", jobid);
|
||||||
const imexMediaServerResponse = await axios.post(
|
if (invoice_number) {
|
||||||
`${bodyshop.localmediaserverhttp}/${
|
formData.append("invoice_number", invoice_number);
|
||||||
invoice_number ? "bills" : "jobs"
|
formData.append("vendorid", vendorid);
|
||||||
}/upload`,
|
}
|
||||||
formData,
|
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
|
||||||
{
|
const mimeType = mime.getType(imageData.uri);
|
||||||
...options,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (imexMediaServerResponse.status !== 200) {
|
let thumb;
|
||||||
if (onError) {
|
let fileData = {
|
||||||
console.log(imexMediaServerResponse);
|
uri: null,
|
||||||
onError(
|
type: null,
|
||||||
imexMediaServerResponse.data || imexMediaServerResponse.statusText
|
name: null,
|
||||||
);
|
};
|
||||||
|
if (mimeType === "image/heic") {
|
||||||
|
try {
|
||||||
|
thumb = await ImageManipulator.manipulateAsync(imageData.uri, [], {
|
||||||
|
format: "jpeg",
|
||||||
|
base64: true,
|
||||||
|
compress: 0.75,
|
||||||
|
});
|
||||||
|
const name = imageData.filename.split(".");
|
||||||
|
name.pop();
|
||||||
|
fileData = {
|
||||||
|
uri: thumb.uri,
|
||||||
|
type: "image/jpeg",
|
||||||
|
name: name.join("") + ".jpeg",
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
onError && onError(error.message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onSuccess && onSuccess();
|
fileData = {
|
||||||
|
uri: imageData.localUri || imageData.uri,
|
||||||
|
type: mimeType,
|
||||||
|
name: filename,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callbackAfterUpload) {
|
console.log("Got past reading the media.", formData);
|
||||||
callbackAfterUpload();
|
formData.append("file", fileData);
|
||||||
|
formData.append("skip_thumbnail", true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const imexMediaServerResponse = await axios.post(
|
||||||
|
`${bodyshop.localmediaserverhttp}/${
|
||||||
|
invoice_number ? "bills" : "jobs"
|
||||||
|
}/upload`,
|
||||||
|
formData,
|
||||||
|
{
|
||||||
|
...options,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"Response Time ",
|
||||||
|
imexMediaServerResponse.headers["x-response-time"]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (imexMediaServerResponse.status !== 200) {
|
||||||
|
if (onError) {
|
||||||
|
console.log(imexMediaServerResponse);
|
||||||
|
onError(
|
||||||
|
imexMediaServerResponse.data || imexMediaServerResponse.statusText
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onSuccess && onSuccess();
|
||||||
|
console.log("Succesful upload", imageData.filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callbackAfterUpload) {
|
||||||
|
callbackAfterUpload();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error uploading documents:", error);
|
||||||
|
onError && onError(error.message);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error uploading documents:", onError, error);
|
console.log("Uncaught error", error);
|
||||||
onError && onError(error.message);
|
onError && onError(error.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
27
yarn.lock
27
yarn.lock
@@ -3060,12 +3060,13 @@ atob@^2.1.2:
|
|||||||
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
||||||
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
||||||
|
|
||||||
axios@^0.21.0:
|
axios@^0.27.2:
|
||||||
version "0.21.4"
|
version "0.27.2"
|
||||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
|
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
|
||||||
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
|
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects "^1.14.0"
|
follow-redirects "^1.14.9"
|
||||||
|
form-data "^4.0.0"
|
||||||
|
|
||||||
babel-core@^7.0.0-bridge.0:
|
babel-core@^7.0.0-bridge.0:
|
||||||
version "7.0.0-bridge.0"
|
version "7.0.0-bridge.0"
|
||||||
@@ -4924,7 +4925,7 @@ flow-parser@^0.121.0:
|
|||||||
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.121.0.tgz#9f9898eaec91a9f7c323e9e992d81ab5c58e618f"
|
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.121.0.tgz#9f9898eaec91a9f7c323e9e992d81ab5c58e618f"
|
||||||
integrity sha512-1gIBiWJNR0tKUNv8gZuk7l9rVX06OuLzY9AoGio7y/JT4V1IZErEMEq2TJS+PFcw/y0RshZ1J/27VfK1UQzYVg==
|
integrity sha512-1gIBiWJNR0tKUNv8gZuk7l9rVX06OuLzY9AoGio7y/JT4V1IZErEMEq2TJS+PFcw/y0RshZ1J/27VfK1UQzYVg==
|
||||||
|
|
||||||
follow-redirects@^1.14.0:
|
follow-redirects@^1.14.9:
|
||||||
version "1.15.0"
|
version "1.15.0"
|
||||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4"
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4"
|
||||||
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==
|
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==
|
||||||
@@ -4948,6 +4949,15 @@ form-data@^3.0.1:
|
|||||||
combined-stream "^1.0.8"
|
combined-stream "^1.0.8"
|
||||||
mime-types "^2.1.12"
|
mime-types "^2.1.12"
|
||||||
|
|
||||||
|
form-data@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||||
|
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||||
|
dependencies:
|
||||||
|
asynckit "^0.4.0"
|
||||||
|
combined-stream "^1.0.8"
|
||||||
|
mime-types "^2.1.12"
|
||||||
|
|
||||||
formik@^2.2.9:
|
formik@^2.2.9:
|
||||||
version "2.2.9"
|
version "2.2.9"
|
||||||
resolved "https://registry.yarnpkg.com/formik/-/formik-2.2.9.tgz#8594ba9c5e2e5cf1f42c5704128e119fc46232d0"
|
resolved "https://registry.yarnpkg.com/formik/-/formik-2.2.9.tgz#8594ba9c5e2e5cf1f42c5704128e119fc46232d0"
|
||||||
@@ -6699,6 +6709,11 @@ mime@^2.4.1, mime@^2.4.4:
|
|||||||
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
|
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
|
||||||
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==
|
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==
|
||||||
|
|
||||||
|
mime@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7"
|
||||||
|
integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==
|
||||||
|
|
||||||
mimic-fn@^1.0.0:
|
mimic-fn@^1.0.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
|
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
|
||||||
|
|||||||
Reference in New Issue
Block a user