Resolve video upload issues.

This commit is contained in:
Patrick Fic
2022-05-14 11:25:44 -07:00
parent e7a76a281f
commit 2ad694ceda
5 changed files with 27 additions and 17 deletions

BIN
build-1652399223268.aab Normal file

Binary file not shown.

View File

@@ -156,21 +156,17 @@ export function UploadProgress({
if (deleteAfterUpload) {
try {
const a = await MediaLibrary.getAssetsAsync();
console.log("assets", a);
console.log("filestodelete", filesToDelete);
const res = await Promise.all(
filesToDelete.map(async (f) =>
MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId)
)
filesToDelete.map((f) => {
return MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId);
})
);
const deleteResult = await MediaLibrary.deleteAssetsAsync(
filesToDelete
);
console.log("res", res);
console.log(
"🚀 ~ file: upload-progress.component.jsx ~ line 177 ~ deleteResult",
filesToDelete,
deleteResult
filesToDelete.map((f) => f.id)
);
} catch (error) {
console.log("Unable to delete picture.", error);

View File

@@ -18,6 +18,7 @@
"@expo/vector-icons": "^13.0.0",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-community/art": "^1.2.0",
"@react-native-community/cli-debugger-ui": "^7.0.3",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/bottom-tabs": "^6.2.0",
"@react-navigation/drawer": "^6.3.1",

View File

@@ -109,7 +109,12 @@ export function* signInSuccessSaga({ payload }) {
const shop = yield client.query({ query: QUERY_BODYSHOP });
logImEXEvent("imexmobile_sign_in_success", payload);
yield put(setBodyshop(shop.data.bodyshops[0]));
yield put(
setBodyshop({
...shop.data.bodyshops[0],
localmediaserverhttp: `http://192.168.1.235:8000`,
})
);
} catch (error) {
console.log("UH-OH. Couldn't get shop details.", error);
}

View File

@@ -8,7 +8,6 @@ export const handleLocalUpload = async ({ ev, context }) => {
const { onError, onSuccess, onProgress, filename, mediaId } = ev;
const { jobid, invoice_number, vendorid, callbackAfterUpload } = context;
const bodyshop = store.getState().user.bodyshop;
var options = {
headers: {
"X-Requested-With": "XMLHttpRequest",
@@ -28,7 +27,13 @@ export const handleLocalUpload = async ({ ev, context }) => {
}
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
const newFile = await (await fetch(imageData.localUri)).blob();
let newFile;
try {
newFile = await (await fetch(imageData.localUri || imageData.uri)).blob();
} catch (error) {
console.log("blobbing error", error, imageData.localUri || imageData.uri);
}
let thumb;
let fileData = {
uri: null,
@@ -51,10 +56,11 @@ export const handleLocalUpload = async ({ ev, context }) => {
};
} catch (error) {
console.log(error);
onError && onError(error.message);
}
} else {
fileData = {
uri: imageData.localUri,
uri: imageData.localUri || imageData.uri,
type: newFile.type,
name: filename,
};
@@ -76,7 +82,9 @@ export const handleLocalUpload = async ({ ev, context }) => {
if (imexMediaServerResponse.status !== 200) {
if (onError) {
console.log(imexMediaServerResponse);
onError(imexMediaServerResponse.statusText);
onError(
imexMediaServerResponse.data || imexMediaServerResponse.statusText
);
}
} else {
onSuccess && onSuccess();
@@ -87,6 +95,6 @@ export const handleLocalUpload = async ({ ev, context }) => {
}
} catch (error) {
console.log("Error uploading documents:", onError, error);
onError && onError(error);
onError && onError(error.message);
}
};