diff --git a/src/frontend/src/components/layout/config/BulkOperations.vue b/src/frontend/src/components/layout/config/BulkOperations.vue
index 210286d..dc9ad2f 100644
--- a/src/frontend/src/components/layout/config/BulkOperations.vue
+++ b/src/frontend/src/components/layout/config/BulkOperations.vue
@@ -26,13 +26,13 @@
validity period
@@ -77,11 +77,11 @@
-
+
No recent bulk operations
-
+
@@ -112,6 +112,7 @@ export default {
importDataset: "NODE",
selectedFileName: null,
selectedFile: null,
+ fileBlob: null, // Blob im RAM gespeichert
uploading: false,
processId: null,
}
@@ -126,7 +127,7 @@ export default {
async isSelected(newVal) {
if(newVal === true)
await this.validityPeriodStore.loadPeriods();
- await this.bulkOperationStore.manageStatus();
+ await this.bulkOperationStore.manageStatus();
}
},
computed: {
@@ -185,22 +186,60 @@ export default {
await this.bulkOperationStore.scheduleDownload(this.exportDataset, isCurrent ? null : this.selectedPeriod);
}
},
- inputFile(event) {
+ async inputFile(event) {
const file = event.target.files[0];
if (file) {
- this.selectedFile = file;
- this.selectedFileName = file.name;
+ try {
+ // Datei sofort in den RAM laden als Blob
+ this.fileBlob = await this.readFileAsBlob(file);
+
+ // File-Objekt mit dem Blob erstellen, das den originalen Namen und Typ behält
+ this.selectedFile = new File([this.fileBlob], file.name, { type: file.type });
+ this.selectedFileName = file.name;
+
+ logger.info(`File loaded into memory: ${file.name} (${(file.size / 1024).toFixed(2)} KB)`);
+ } catch (error) {
+ logger.error('Error reading file:', error);
+ this.selectedFile = null;
+ this.selectedFileName = null;
+ this.fileBlob = null;
+ }
} else {
this.selectedFile = null;
this.selectedFileName = null;
+ this.fileBlob = null;
}
+
+ // Input zurücksetzen, damit dieselbe Datei erneut ausgewählt werden kann
+ event.target.value = '';
+ },
+ readFileAsBlob(file) {
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+
+ reader.onload = (e) => {
+ // ArrayBuffer in Blob konvertieren
+ const blob = new Blob([e.target.result], { type: file.type });
+ resolve(blob);
+ };
+
+ reader.onerror = (error) => {
+ reject(error);
+ };
+
+ // Datei als ArrayBuffer lesen
+ reader.readAsArrayBuffer(file);
+ });
},
async uploadFile() {
if (!this.selectedFile)
return;
- await this.bulkOperationStore.scheduleUpload(this.importDataset, this.selectedFile);
+ const file = this.selectedFile;
+ this.selectedFile = null;
+ this.selectedFileName = null;
+ await this.bulkOperationStore.scheduleUpload(this.importDataset, file);
}
}
}