(
baseUrl: string,
relativePath: string,
options: FetchManifestFileOptions = {}
)
| 624 | } |
| 625 | |
| 626 | export async function fetchManifestFile( |
| 627 | baseUrl: string, |
| 628 | relativePath: string, |
| 629 | options: FetchManifestFileOptions = {} |
| 630 | ): Promise<File> { |
| 631 | const fetchImpl = options.fetchImpl ?? defaultFetchUrl; |
| 632 | const fullUrl = joinManifestUrlPath(baseUrl, relativePath); |
| 633 | const response = await fetchImpl(fullUrl); |
| 634 | |
| 635 | if (!response.ok) { |
| 636 | const errorType: UrlLoadErrorType = response.status === 404 ? 'not_found' : 'network'; |
| 637 | const error: UrlLoadError = { |
| 638 | type: errorType, |
| 639 | message: `Failed to fetch file (${response.status})`, |
| 640 | details: `${relativePath}: ${response.statusText}`, |
| 641 | failedFile: fullUrl, |
| 642 | }; |
| 643 | throw error; |
| 644 | } |
| 645 | |
| 646 | const blob = await readResponseToBlob(response, options.onProgress); |
| 647 | const filename = getFilenameFromUrl(fullUrl); |
| 648 | return blobToFile(blob, filename); |
| 649 | } |
| 650 | |
| 651 | export async function fetchManifestColmapFiles( |
| 652 | manifest: ColmapManifest, |
no test coverage detected