family update
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
export async function fetchAuthenticatedMediaBlob(accessUrl: string, token: string) {
|
||||
export async function fetchAuthenticatedMediaBlob(accessUrl: string, token: string, mimeType?: string) {
|
||||
const response = await fetch(accessUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Не удалось загрузить файл');
|
||||
}
|
||||
return response.blob();
|
||||
const raw = await response.blob();
|
||||
if (mimeType && (!raw.type || raw.type === 'application/octet-stream')) {
|
||||
return new Blob([await raw.arrayBuffer()], { type: mimeType });
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
export function createBlobObjectUrl(blob: Blob) {
|
||||
|
||||
Reference in New Issue
Block a user