mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 22:32:26 +03:00
Fix authenticated media download (#1947)
* remove dead function * fix media download in room timeline * authenticate remaining media endpoints
This commit is contained in:
parent
f2c31d29a2
commit
03cc25eec0
13 changed files with 284 additions and 207 deletions
|
@ -273,3 +273,20 @@ export const mxcUrlToHttp = (
|
|||
allowRedirects,
|
||||
useAuthentication
|
||||
);
|
||||
|
||||
export const downloadMedia = async (src: string): Promise<Blob> => {
|
||||
// this request is authenticated by service worker
|
||||
const res = await fetch(src, { method: 'GET' });
|
||||
const blob = await res.blob();
|
||||
return blob;
|
||||
};
|
||||
|
||||
export const downloadEncryptedMedia = async (
|
||||
src: string,
|
||||
decryptContent: (buf: ArrayBuffer) => Promise<Blob>
|
||||
): Promise<Blob> => {
|
||||
const encryptedContent = await downloadMedia(src);
|
||||
const decryptedContent = await decryptContent(await encryptedContent.arrayBuffer());
|
||||
|
||||
return decryptedContent;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue