coyotte508 HF staff commited on
Commit
9d7e455
1 Parent(s): 791fff8

♻️ Directly upload from remote file

Browse files
Files changed (2) hide show
  1. app.ts +7 -6
  2. dist/app.js +7 -6
app.ts CHANGED
@@ -3,11 +3,11 @@ import { createRepo, commit, CommitFile, whoAmI } from "@huggingface/hub";
3
  const c = console;
4
 
5
  const FILES_TO_UPLOAD = [
6
- "./mobilenet/model.json",
7
- "./mobilenet/group1-shard1of2",
8
- "./mobilenet/group1-shard2of2",
9
- "./mobilenet/coffee.jpg",
10
- "./mobilenet/README.md",
11
  ];
12
 
13
  function filenameFromURL(url: string): string {
@@ -62,7 +62,8 @@ window.document.addEventListener("DOMContentLoaded", () => {
62
  return {
63
  operation: "addOrUpdate",
64
  path: filenameFromURL(file),
65
- content: await (await fetch(file)).blob(),
 
66
  };
67
  })
68
  );
 
3
  const c = console;
4
 
5
  const FILES_TO_UPLOAD = [
6
+ `${window.location.origin}${window.location.pathname}/mobilenet/model.json`,
7
+ `${window.location.origin}${window.location.pathname}/mobilenet/group1-shard1of2`,
8
+ `${window.location.origin}${window.location.pathname}/mobilenet/group1-shard2of2`,
9
+ `${window.location.origin}${window.location.pathname}/mobilenet/coffee.jpg`,
10
+ `${window.location.origin}${window.location.pathname}/mobilenet/README.md`,
11
  ];
12
 
13
  function filenameFromURL(url: string): string {
 
62
  return {
63
  operation: "addOrUpdate",
64
  path: filenameFromURL(file),
65
+ // upload remote file
66
+ content: new URL(file),
67
  };
68
  })
69
  );
dist/app.js CHANGED
@@ -1,11 +1,11 @@
1
  import { createRepo, commit, whoAmI } from "@huggingface/hub";
2
  const c = console;
3
  const FILES_TO_UPLOAD = [
4
- "./mobilenet/model.json",
5
- "./mobilenet/group1-shard1of2",
6
- "./mobilenet/group1-shard2of2",
7
- "./mobilenet/coffee.jpg",
8
- "./mobilenet/README.md",
9
  ];
10
  function filenameFromURL(url) {
11
  return url.substring(url.lastIndexOf("/") + 1);
@@ -49,7 +49,8 @@ window.document.addEventListener("DOMContentLoaded", () => {
49
  return {
50
  operation: "addOrUpdate",
51
  path: filenameFromURL(file),
52
- content: await (await fetch(file)).blob(),
 
53
  };
54
  }));
55
  const commitOutput = await commit({
 
1
  import { createRepo, commit, whoAmI } from "@huggingface/hub";
2
  const c = console;
3
  const FILES_TO_UPLOAD = [
4
+ `${window.location.origin}${window.location.pathname}/mobilenet/model.json`,
5
+ `${window.location.origin}${window.location.pathname}/mobilenet/group1-shard1of2`,
6
+ `${window.location.origin}${window.location.pathname}/mobilenet/group1-shard2of2`,
7
+ `${window.location.origin}${window.location.pathname}/mobilenet/coffee.jpg`,
8
+ `${window.location.origin}${window.location.pathname}/mobilenet/README.md`,
9
  ];
10
  function filenameFromURL(url) {
11
  return url.substring(url.lastIndexOf("/") + 1);
 
49
  return {
50
  operation: "addOrUpdate",
51
  path: filenameFromURL(file),
52
+ // upload remote file
53
+ content: new URL(file),
54
  };
55
  }));
56
  const commitOutput = await commit({