refactor(upload): use IncomingFile interface instead of multipart headers
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m58s

Refactors the upload handler to use the `services.IncomingFile` interface instead of concrete `*multipart.FileHeader` pointers. This decouples the core upload logic from the HTTP multipart implementation, allowing for more flexible file sources.

Changes include:
- Introducing `namedMultipartFile` to adapt multipart headers to the new interface.
- Updating `createOrAppendBox`, `checkUploadPolicy`, and `totalUploadBytes` to accept `IncomingFile`.
- Renaming service calls to `CreateBoxFromIncoming` and `AppendIncomingFiles`.
This commit is contained in:
2026-06-10 18:19:45 +03:00
parent 5d77b36634
commit 6a7590493c
4 changed files with 76 additions and 23 deletions

View File

@@ -411,7 +411,7 @@
data: { url: window.Warpbox.absoluteURL(url || "/") },
};
try {
const registration = await navigator.serviceWorker?.ready;
const registration = navigator.serviceWorker ? await navigator.serviceWorker.ready : null;
if (registration && registration.showNotification) {
await registration.showNotification(title, options);
return;
@@ -419,14 +419,18 @@
} catch (error) {
/* fall through to page notification */
}
const notification = new Notification(title, options);
notification.onclick = () => {
window.focus();
if (url) {
window.location.href = window.Warpbox.absoluteURL(url);
}
notification.close();
};
try {
const notification = new Notification(title, options);
notification.onclick = () => {
window.focus();
if (url) {
window.location.href = window.Warpbox.absoluteURL(url);
}
notification.close();
};
} catch (error) {
/* notifications are best-effort */
}
}
function notify(variant, message, options) {
@@ -1410,8 +1414,10 @@
function uploadFormData() {
const formData = new FormData(form);
formData.delete("file");
formData.delete("file_path");
selectedFiles.forEach((file) => {
formData.append("file", file, uploadName(file));
formData.append("file_path", uploadName(file));
});
return formData;
}