mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 11:49:25 +00:00
Use ffmpeg
This commit is contained in:
@@ -2406,7 +2406,9 @@ export function createAdminConsole({
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Upload failed");
|
||||
return extractErrorMessage(response, "Upload failed").then((message) => {
|
||||
throw new Error(message);
|
||||
});
|
||||
}
|
||||
if (fileInput) {
|
||||
fileInput.value = "";
|
||||
@@ -2421,10 +2423,31 @@ export function createAdminConsole({
|
||||
}
|
||||
console.error(e);
|
||||
removePendingUpload(pendingId);
|
||||
showToast("Upload failed. Please try again with a supported file.", "error");
|
||||
showToast(e?.message || "Upload failed. Please try again with a supported file.", "error");
|
||||
});
|
||||
}
|
||||
|
||||
function extractErrorMessage(response, fallback) {
|
||||
if (!response) {
|
||||
return Promise.resolve(fallback);
|
||||
}
|
||||
return response
|
||||
.json()
|
||||
.then((data) => {
|
||||
if (data?.message) {
|
||||
return data.message;
|
||||
}
|
||||
if (data?.error) {
|
||||
return data.error;
|
||||
}
|
||||
if (typeof data === "string" && data.trim()) {
|
||||
return data;
|
||||
}
|
||||
return fallback;
|
||||
})
|
||||
.catch(() => response.text().then((text) => text?.trim() || fallback).catch(() => fallback));
|
||||
}
|
||||
|
||||
function getCanvasPoint(event) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const scaleX = canvas.width / rect.width;
|
||||
|
||||
Reference in New Issue
Block a user