Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Show Upload Error
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlauer-Hax committed Dec 6, 2024
1 parent aedd914 commit 438c5ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/admin/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function upload(type: keyof typeof urls): Promise<string> {
return new Promise((resolve) => {
createFilePicker(extension).then((file) => {
StreamingUploadHandler(url, {
failure: () => alert("Your Upload has failed. Please try a different file or try again later"),
failure: (message) => alert("Your Upload has failed. Please try a different file or try again later. " + message),
uploadDone: () => console.log("Upload done"),
credentials: () => API.getToken(),
backendResponse: (id) => resolve(id),
Expand Down
6 changes: 3 additions & 3 deletions pages/shared/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type StreamingUploadEvents = {
onUploadTick: (percentage: number) => Promise<void>;
uploadDone: () => void;
backendResponse: (id: string) => void;
failure: () => void;
failure: (message: string) => void;
};

export function ProgressTracker(percentage: Reference<number>, expectedSize: number) {
Expand Down Expand Up @@ -38,9 +38,9 @@ export function StreamingUploadHandler(path: string, events: StreamingUploadEven
const reader = stream.getReader();

ws.onmessage = async ({ data }) => {
if (data == "failed") {
if (data.startsWith("failed")) {
console.log("Looks like we failed.");
events.failure();
events.failure(data);
} else if (data == "file") {
ws.send(`file ${JSON.stringify({ filename: file.name, type: file.type })}`);
} else if (data == "next") {
Expand Down

0 comments on commit 438c5ee

Please sign in to comment.