wxh*_*wxh 1 multipartform-data typescript visual-studio-code vscode-extensions
我正在编写一个扩展,需要通过多部分表单数据上传选定的文件。
我找到了一些片段,例如Cannot POST a multipart/form-data using Fetch TYPESCRIPT,并写了类似的内容:
window.showOpenDialog({
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
filters: {
'image': ['jpg', 'png'],
},
title: 'Add Image',
}).then(async uriList => {
if (undefined === uriList || uriList.length === 0) {
return;
}
let imageFile = createReadStream(uriList[0].fsPath);
let formData = new FormData();
formData.append('file', imageFile); // <- ts(2345) error
});
Run Code Online (Sandbox Code Playgroud)
然而它抱怨:
Argument of type 'ReadStream' is not assignable to parameter of type 'string | Blob'.
Type 'ReadStream' is missing the following properties from type 'Blob': size, type, arrayBuffer, slice, and 2 more.ts(2345)
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
| 归档时间: |
|
| 查看次数: |
6685 次 |
| 最近记录: |