图片上传hash 有bug,修复

This commit is contained in:
2025-12-03 18:05:40 +08:00
parent a97f015205
commit 87824c0021
6 changed files with 27 additions and 10 deletions

View File

@@ -79,12 +79,15 @@ export const upload = (opts: UploadOptions): Promise<{ code?: number; message?:
value = opts.file;
}
form.append('file', value);
const fileSize = Buffer.byteLength(value);
if (opts.needHash) {
hash = opts?.hash || getBufferHash(value);
opts.url = new URL(opts.url.toString());
opts.url.searchParams.append('hash', hash);
opts.url.searchParams.append('size', fileSize.toString());
}
}
console.log('上传文件到', opts.url.toString());
const headers = form.getHeaders();
return new Promise((resolve) => {
form.submit(getFormParams(opts, headers), (err, res) => {