mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-04-24 22:25:07 +00:00
fix: use string fields instead of JSON blob for HuggingFace commit API
This commit is contained in:
@@ -109,22 +109,19 @@ export class HuggingFaceAPI {
|
||||
console.log('Commit URL:', commitUrl);
|
||||
|
||||
// 构建 multipart form data
|
||||
// HuggingFace commit API 格式参考: https://huggingface.co/docs/huggingface.js
|
||||
// HuggingFace commit API 需要特定格式
|
||||
const formData = new FormData();
|
||||
|
||||
// header 必须是 JSON blob,包含 summary
|
||||
const header = {
|
||||
summary: commitMessage,
|
||||
description: ''
|
||||
};
|
||||
formData.append('header', new Blob([JSON.stringify(header)], { type: 'application/json' }));
|
||||
// 直接添加字符串字段
|
||||
formData.append('summary', commitMessage);
|
||||
formData.append('description', '');
|
||||
|
||||
// 添加文件操作描述
|
||||
const operations = [{
|
||||
// 添加文件操作描述 - 作为字符串
|
||||
const operations = JSON.stringify([{
|
||||
key: 'file-0',
|
||||
path: filePath
|
||||
}];
|
||||
formData.append('operations', new Blob([JSON.stringify(operations)], { type: 'application/json' }));
|
||||
}]);
|
||||
formData.append('operations', operations);
|
||||
|
||||
// 添加文件,key 必须与 operations 中的 key 匹配
|
||||
formData.append('file-0', file, filePath.split('/').pop());
|
||||
|
||||
Reference in New Issue
Block a user