Add function to download and decrypt a file
This commit is contained in:
parent
01e57a212b
commit
580ce23c17
1 changed files with 13 additions and 0 deletions
|
@ -92,3 +92,16 @@ export const getPreview = async (token: string, file: file) => {
|
|||
file.key);
|
||||
return URL.createObjectURL(new Blob([decrypted]));
|
||||
}
|
||||
|
||||
export const getFile = async (token: string, file: file) => {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/files/download/${file.id}`,
|
||||
{ token }, null, { responseType: 'arraybuffer' },
|
||||
);
|
||||
const worker = await new CryptoWorker();
|
||||
const decrypted: any = await worker.decryptFile(
|
||||
new Uint8Array(resp.data),
|
||||
await worker.fromB64(file.file.decryptionHeader),
|
||||
file.key);
|
||||
return URL.createObjectURL(new Blob([decrypted]));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue