Skip to content

Commit

Permalink
Merge pull request #1203 from fdm-monster/fix/fdmm-2321-zip-download-…
Browse files Browse the repository at this point in the history
…sometimes-corrupt

Fix/fdmm 2321 zip download sometimes corrupt
  • Loading branch information
davidzwa authored Apr 19, 2024
2 parents 78036b8 + 33c8313 commit 79117b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Client develop

# Client 18/04/2024 1.5.14

Fixes;
- fix: ZIP download would be corrupt sometimes. Ensure file downloaded as ArrayBuffer (instead of blob) and written as text/plain instead of text.

# Client 18/04/2024 1.5.13

Features:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fdm-monster/client",
"version": "1.5.13",
"version": "1.5.14",
"author": "David Zwart",
"license": "AGPL-3.0-or-later",
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions src/backend/server-private.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export class ServerPrivateService extends BaseService {
method: "POST",
url: `api/server/export-printers-floors-yaml`,
data: input,
responseType: "blob",
responseType: "arraybuffer",
});
downloadFileByBlob((response as any).data as any, "export-fdm-monster-" + Date.now() + ".yaml");
downloadFileByBlob(response.data as ArrayBuffer, "export-fdm-monster-" + Date.now() + ".yaml");
}

public static async uploadAndImportYaml(file: File) {
Expand All @@ -33,9 +33,9 @@ export class ServerPrivateService extends BaseService {
const response = await client.request<any>({
method: "POST",
url: `api/server/dump-fdm-monster-logs`,
responseType: "blob",
responseType: "arraybuffer",
});
downloadFileByBlob((response as any).data, "logs-fdm-monster-" + Date.now() + ".zip");
downloadFileByBlob(response.data as ArrayBuffer, "logs-fdm-monster-" + Date.now() + ".zip");
}

public static async clearLogFilesOlderThanWeek() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/download-file.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function downloadFileByBlob(data: ArrayBuffer, fileName: string) {
if (!data) {
throw new Error("No data to download");
}
const blob = new Blob([data], { type: "text" });
const blob = new Blob([data], { type: "text/plain" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = fileName;
Expand Down

0 comments on commit 79117b0

Please sign in to comment.