(
endpoint: string,
data: unknown[],
api_info: any,
token?: `hf_${string}`
)
| 705 | } |
| 706 | |
| 707 | async function handle_blob( |
| 708 | endpoint: string, |
| 709 | data: unknown[], |
| 710 | api_info: any, |
| 711 | token?: `hf_${string}` |
| 712 | ): Promise<unknown[]> { |
| 713 | const blob_refs = await walk_and_store_blobs( |
| 714 | data, |
| 715 | undefined, |
| 716 | [], |
| 717 | true, |
| 718 | api_info |
| 719 | ); |
| 720 | |
| 721 | return Promise.all( |
| 722 | blob_refs.map( |
| 723 | async ({ |
| 724 | path, |
| 725 | blob, |
| 726 | data, |
| 727 | type, |
| 728 | }: { |
| 729 | path: string; |
| 730 | blob: Blob; |
| 731 | data: string; |
| 732 | type: string; |
| 733 | }) => { |
| 734 | if (blob) { |
| 735 | const file_url = (await upload_files(endpoint, [blob], token)) |
| 736 | ?.files?.[0]; |
| 737 | return { path, file_url, type }; |
| 738 | } else { |
| 739 | return { path, base64: data, type }; |
| 740 | } |
| 741 | } |
| 742 | ) |
| 743 | ).then((r) => { |
| 744 | r.forEach(({ path, file_url, base64, type }) => { |
| 745 | if (base64) { |
| 746 | update_object(data, base64, path); |
| 747 | } else if (type === "Gallery") { |
| 748 | update_object(data, file_url, path); |
| 749 | } else if (file_url) { |
| 750 | const o = { |
| 751 | is_file: true, |
| 752 | name: `${file_url}`, |
| 753 | data: null, |
| 754 | // orig_name: "file.csv" |
| 755 | }; |
| 756 | update_object(data, o, path); |
| 757 | } |
| 758 | }); |
| 759 | |
| 760 | return data; |
| 761 | }); |
| 762 | } |
| 763 | } |
| 764 |
no test coverage detected