From 2eb77b6712f6c0e140ed98d52559e33b52b67d52 Mon Sep 17 00:00:00 2001 From: Eliott C Date: Thu, 9 Nov 2023 15:14:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Document=20uploadFilesWithProgre?= =?UTF-8?q?ss=20(#289)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/hub/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/hub/README.md b/packages/hub/README.md index d5ae9298e..e015fc1e5 100644 --- a/packages/hub/README.md +++ b/packages/hub/README.md @@ -28,7 +28,7 @@ Check out the [full documentation](https://huggingface.co/docs/huggingface.js/hu For some of the calls, you need to create an account and generate an [access token](https://huggingface.co/settings/tokens). ```ts -import { createRepo, uploadFiles, deleteFile, deleteRepo, listFiles, whoAmI } from "@huggingface/hub"; +import { createRepo, uploadFiles, uploadFilesWithProgress, deleteFile, deleteRepo, listFiles, whoAmI } from "@huggingface/hub"; import type { RepoDesignation, Credentials } from "@huggingface/hub"; const repo: RepoDesignation = { type: "model", name: "myname/some-model" }; @@ -64,6 +64,18 @@ await uploadFiles({ ], }); +// or + +for await (const progressEvent of await uploadFilesWithProgress({ + repo, + credentials, + files: [ + ... + ], +})) { + console.log(progressEvent); +} + await deleteFile({repo, credentials, path: "myfile.bin"}); await (await downloadFile({ repo, path: "README.md" })).text();