multimodalart HF Staff commited on
Commit
75e5313
·
1 Parent(s): 6d312fd

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +27 -8
index.html CHANGED
@@ -81,12 +81,30 @@
81
  }
82
 
83
  try {
84
- // upload files
85
- await uploadFiles({
86
- repo: REPO_ID,
87
- credentials: { accessToken: HF_ACCESS_TOKEN },
88
- files: files.map(file => ({path: file.name, content: file}))
89
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  console.log(`All files uploaded successfully`);
92
 
@@ -107,7 +125,8 @@
107
  let time5GB = (5 * 1024 / speed) / 60;
108
  let time10GB = (10 * 1024 / speed) / 60;
109
 
110
- messageDiv.innerHTML = `All files uploaded successfully in ${elapsedTime.toFixed(2)} seconds, for all ${totalSize.toFixed(2)} MB in the ${files.length} files, speed ${speed.toFixed(2)} MB/s.<br>To upload a 1GB model at this speed, it would take approximately ${time1GB.toFixed(2)} minutes.<br>To upload a 5GB model at this speed, it would take approximately ${time5GB.toFixed(2)} minutes.<br>To upload a 10GB model at this speed, it would take approximately ${time10GB.toFixed(2)} minutes.`;
 
111
  processingMessage.textContent = "All files processed";
112
  } else {
113
  messageDiv.textContent = 'Please select files to upload';
@@ -115,4 +134,4 @@
115
  }
116
  </script>
117
  </body>
118
- </html>
 
81
  }
82
 
83
  try {
84
+ // upload files in chunks
85
+ for (let file of files) {
86
+ const chunkSize = 1024 * 1024; // 1MB
87
+ let start = 0;
88
+ let end = chunkSize;
89
+ let index = 0;
90
+
91
+ while (start < file.size) {
92
+ const chunk = file.slice(start, end);
93
+ chunk.name = `${file.name}.chunk${index}`; // chunk naming convention
94
+ start = end;
95
+ end = start + chunkSize;
96
+ index++;
97
+
98
+ await uploadFiles({
99
+ repo: REPO_ID,
100
+ credentials: { accessToken: HF_ACCESS_TOKEN },
101
+ files: [{ path: chunk.name, content: chunk }],
102
+ });
103
+
104
+ // update progress bar
105
+ progressBar.value = (start / file.size) * 100;
106
+ }
107
+ }
108
 
109
  console.log(`All files uploaded successfully`);
110
 
 
125
  let time5GB = (5 * 1024 / speed) / 60;
126
  let time10GB = (10 * 1024 / speed) / 60;
127
 
128
+ // Update the message with upload statistics
129
+ messageDiv.innerHTML = `All files uploaded successfully in ${elapsedTime.toFixed(2)} seconds, for all ${totalSize.toFixed(2)} MB in the ${files.length} files, speed ${speed.toFixed(2)} MB/s. <br> To upload a 1GB model at this speed, it would take approximately ${time1GB.toFixed(2)} minutes. <br> To upload a 5GB model at this speed, it would take approximately ${time5GB.toFixed(2)} minutes. <br> To upload a 10GB model at this speed, it would take approximately ${time10GB.toFixed(2)} minutes.`;
130
  processingMessage.textContent = "All files processed";
131
  } else {
132
  messageDiv.textContent = 'Please select files to upload';
 
134
  }
135
  </script>
136
  </body>
137
+ </html>