Fix authenticated media download (#1947)
* remove dead function * fix media download in room timeline * authenticate remaining media endpoints
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user