jdk的封装的fetcher,上传图片报错,
实现场景:
请简单描述你想要实现的原始场景,例如:我想要实现xxx的功能... 我想要fetcher能够实现上传图片的效果
存在的问题:
请简单描述你现在遇到的不符合预期的问题... 上传失败
当前方案:
请粘贴你当前方案的完整 amis schema 代码...
json文件内容{ "type": "input-image", "label": "图片集", "name": "album", "autoUpload": true, "proxy": true, "uploadType": "fileReceptor", "imageClassName": "r w-full", "id": "u:aaad6b6d58f9", "accept": ".jpeg, .jpg, .png, .gif", "multiple": true, "hideUploadButton": false, "fixedSize": false, "receiver": { "url": "$api_domain/api/cms/information/upload2?url\u003dalbum", "method": "post", "messages": {}, "dataType": "form-data" } },
封装的fetcher {
fetcher: function (params) {
var data = params.data;
var body =params.body
var method = params.method;
var query =params.query
var url = params.url;
return new Promise(function (resolve, reject) {
fetch(url, {
method: method,
body:data,
headers: new Headers({
"Content-Type": "application/json"
}),
})
.then(function (res) {
// console.log(123, res);
return res.json();
})
.then(function (response) {
console.log(1111,response);
resolve({
data: response,
});
});
});
},
}
code here...
👍 Thanks for this! 🏷 I have applied any labels matching special text in your issue.
Please review the labels and make any necessary changes.
headers: new Headers({
"Content-Type": "application/json"
}),
如果 data 是 blob 不要去设置 header
感谢,问题已解决