File size: 745 Bytes
1688a3c
 
7e19cbb
 
 
56f5287
7e19cbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { uploadFiles } from "./../../node_modules/@huggingface/hub/dist";
import type { RepoDesignation, Credentials } from "./../../node_modules/@huggingface/hub/dist";

export const UploaderDataset = async (blob: Blob, name: string) => {
  const repo: RepoDesignation = { type: "dataset", name: "enzostvs/stable-diffusion-tpu-generations" };
  const credentials: Credentials = { accessToken: process.env.NEXT_APP_HF_TOKEN as string };

  const res: any = await uploadFiles({
    repo,
    credentials,
    files: [
      {
        path: `images/${name}.png`,
        content: blob,
      },
    ],
  });

  if (res?.error) return {
    status: 500,
    ok: false,
    message: res?.error
  };

  return {
    status: 200,
    ok: true,
  };

}