1 | |
2 | * Load metadata of the file |
3 | * |
4 | */ |
5 | export async function main(workspace: string, file_key: string | undefined) { |
6 | const url = new URL( |
7 | `${BASE_URL}/api/w/${workspace}/job_helpers/load_file_metadata` |
8 | ); |
9 | for (const [k, v] of [["file_key", file_key]]) { |
10 | if (v !== undefined && v !== "") { |
11 | url.searchParams.append(k, v); |
12 | } |
13 | } |
14 | const response = await fetch(url, { |
15 | method: "GET", |
16 | headers: { |
17 | Authorization: "Bearer " + WM_TOKEN, |
18 | }, |
19 | body: undefined, |
20 | }); |
21 | if (!response.ok) { |
22 | const text = await response.text(); |
23 | throw new Error(`${response.status} ${text}`); |
24 | } |
25 | return await response.json(); |
26 | } |
27 |
|