mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 00:10:57 +00:00
Merge pull request #767 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
This commit is contained in:
@@ -24,3 +24,20 @@ export async function downloadBookingFile(
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /files/:id is authenticated (global JwtGuard) — raw browser loads
|
||||
* (<img>/<iframe>/<a href>) carry no Bearer token and 401. Fetch the bytes
|
||||
* through the axios client and hand the viewer a blob object URL instead.
|
||||
*/
|
||||
export async function fetchViewableFile(
|
||||
id: string,
|
||||
name: string,
|
||||
): Promise<{ name: string; url: string; mimeType?: string }> {
|
||||
const blob = await filesService.download(id);
|
||||
return {
|
||||
name,
|
||||
url: URL.createObjectURL(blob),
|
||||
mimeType: blob.type || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user