Sniff image MIME for ZK viewer blobs so save-as gets a real extension.

This commit is contained in:
2026-11-01 15:32:25 +01:00
parent 402e9df255
commit fb482a1052
5 changed files with 182 additions and 1 deletions
+4 -1
View File
@@ -3,6 +3,7 @@ import { ref } from 'vue';
import { api } from '@/plugins/axios';
import type { GetZkUploadCiphertextResult } from '@/types/upload/GetZkUploadCiphertextResult';
import { base64ToBytes } from '@/utils/encoding/base64ToBytes';
import { detectImageMimeType } from '@/utils/file/detectImageMimeType';
import { toArrayBuffer } from '@/utils/toArrayBuffer';
import { decryptPasswordProtectedZkUpload } from '@/utils/upload/decryptPasswordProtectedZkUpload';
import { decryptZkUpload } from '@/utils/upload/decryptZkUpload';
@@ -67,7 +68,9 @@ export const useZkViewStore = defineStore('zkView', () => {
throw new Error('Could not build image blob');
}
imageObjectUrl.value = URL.createObjectURL(new Blob([buffer]));
const mimeType = await detectImageMimeType(plaintext);
imageObjectUrl.value = URL.createObjectURL(new Blob([buffer], { type: mimeType }));
};
return {