Update index.html
Browse files- index.html +8 -21
index.html
CHANGED
|
@@ -1106,30 +1106,17 @@
|
|
| 1106 |
|
| 1107 |
existing.push(generateDataset());
|
| 1108 |
const content = JSON.stringify(existing, null, 2);
|
| 1109 |
-
const fileBlob = new Blob([content], { type: 'application/json' });
|
| 1110 |
|
| 1111 |
showStatus('Uploading…', 'success');
|
| 1112 |
|
| 1113 |
-
//
|
| 1114 |
-
const
|
| 1115 |
-
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
| 1119 |
-
|
| 1120 |
-
|
| 1121 |
-
path: "data.json"
|
| 1122 |
-
}]
|
| 1123 |
-
};
|
| 1124 |
-
formData.append('header', new Blob([JSON.stringify(header)], { type: 'application/json' }));
|
| 1125 |
-
|
| 1126 |
-
// File part — key must match the path
|
| 1127 |
-
formData.append('file-0', fileBlob, 'data.json');
|
| 1128 |
-
|
| 1129 |
-
const r = await fetch(`https://huggingface.co/api/datasets/${repoId}/commit/main`, {
|
| 1130 |
-
method: "POST",
|
| 1131 |
-
headers: { "Authorization": `Bearer ${token}` },
|
| 1132 |
-
body: formData
|
| 1133 |
});
|
| 1134 |
|
| 1135 |
if (!r.ok) {
|
|
|
|
| 1106 |
|
| 1107 |
existing.push(generateDataset());
|
| 1108 |
const content = JSON.stringify(existing, null, 2);
|
|
|
|
| 1109 |
|
| 1110 |
showStatus('Uploading…', 'success');
|
| 1111 |
|
| 1112 |
+
// Use the upload file API instead
|
| 1113 |
+
const r = await fetch(`https://huggingface.co/api/datasets/${repoId}/upload/main/data.json`, {
|
| 1114 |
+
method: "PUT",
|
| 1115 |
+
headers: {
|
| 1116 |
+
"Authorization": `Bearer ${token}`,
|
| 1117 |
+
"Content-Type": "application/json"
|
| 1118 |
+
},
|
| 1119 |
+
body: content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1120 |
});
|
| 1121 |
|
| 1122 |
if (!r.ok) {
|