Upload improvements for imgproxy.

This commit is contained in:
Patrick Fic
2025-10-31 09:38:51 -07:00
parent ab8703a524
commit beb1145f98
11 changed files with 43 additions and 24 deletions

View File

@@ -39,7 +39,7 @@ const photosReducer = (state = INITIAL_STATE, action) => {
return {
...state,
progress: { ...state.progress, [action.payload.assetId]: { ...state.progress[action.payload.assetId], progress: 100, status: 'completed', endTime: new Date() } },
progress: { ...state.progress, [action.payload.assetId]: { ...state.progress[action.payload.assetId], progress: 1, status: 'completed', endTime: new Date() } },
cancelTasks: remainingTasks
};
case PhotosActionTypes.MEDIA_UPLOAD_PROGRESS_UPDATE_BULK:
@@ -53,7 +53,7 @@ const photosReducer = (state = INITIAL_STATE, action) => {
uploadInProgress: false,
uploadError: null,
photos: [],
progress: {},
// progress: {},
cancelTasks: {}
};
case PhotosActionTypes.CLEAR_UPLOAD_ERROR:
@@ -83,6 +83,12 @@ const photosReducer = (state = INITIAL_STATE, action) => {
...state,
cancelTriggered: true,
};
case PhotosActionTypes.DELETE_MEDIA_SUCCESS: {
return {
...state,
progress: {}, //Clear it here so we only delete photos that were successful.
}
}
default:
return state;
}

View File

@@ -243,6 +243,7 @@ function* uploadToLocalMediaServer(photos, bodyshop, jobid) {
} catch (error) {
console.log("Uncaught error", error);
}
}
function* uploadToImageProxy(photo, photoBlob, extension, key, bodyshop, jobid) {
@@ -297,7 +298,6 @@ function* uploadToImageProxy(photo, photoBlob, extension, key, bodyshop, jobid)
const sent = progressData.totalBytesSent;
const total = progressData.totalBytesExpectedToSend;
const progress = sent / total;
console.log(progress, sent)
store.dispatch(mediaUploadProgressOne({ ...photo, progress, loaded: sent }));
// onUpload(Number(progress.toFixed(2)) * 100);
},
@@ -347,7 +347,7 @@ function* uploadToImageProxy(photo, photoBlob, extension, key, bodyshop, jobid)
],
},
}));
console.log("Upload and record creation successful for", photo.uri);
} else {
console.log("Error uploading to Cloud", uploadResult);
throw new Error(`Cloud upload failed: ${uploadResult}`);
@@ -393,8 +393,9 @@ function* mediaUploadCompletedAction({ payload: photos }) {
}
try {
const progress = yield select((state) => state.photos.progress);
// Handle the completion of media uploads
const filesToDelete = [...photos]
const filesToDelete = Object.keys(progress).filter((key) => progress[key].status === 'completed').map((key) => progress[key]);
if (Platform.OS === "android") {
//Create a new asset with the first file to delete.