IndexxedDb refactored

This commit is contained in:
Reece
2025-06-04 19:04:56 +01:00
parent a3c4f1a305
commit 16f150a203
17 changed files with 1856 additions and 218 deletions
+18 -2
View File
@@ -12,9 +12,11 @@ import {
import { useSearchParams } from "react-router-dom";
import { useTranslation } from "react-i18next";
import DownloadIcon from "@mui/icons-material/Download";
import { FileWithUrl } from "../types/file";
import { fileStorage } from "../services/fileStorage";
export interface SplitPdfPanelProps {
file: { file: File; url: string } | null;
file: { file: FileWithUrl; url: string } | null;
downloadUrl?: string | null;
setDownloadUrl: (url: string | null) => void;
params: {
@@ -68,7 +70,21 @@ const SplitPdfPanel: React.FC<SplitPdfPanelProps> = ({
}
const formData = new FormData();
formData.append("fileInput", file.file);
// Handle IndexedDB files
if (!file.file.id) {
setStatus(t("noFileSelected"));
return;
}
const storedFile = await fileStorage.getFile(file.file.id);
if (storedFile) {
const blob = new Blob([storedFile.data], { type: storedFile.type });
const actualFile = new File([blob], storedFile.name, {
type: storedFile.type,
lastModified: storedFile.lastModified
});
formData.append("fileInput", actualFile);
}
let endpoint = "";