【发布时间】:2019-02-08 08:29:52
【问题描述】:
我将 react、redux 用于后端,将 jsx 用于需要将图像文件作为用户输入并将其发送到某个 api 以上传的项目。 这是我的代码:
函数发布(请求){
let config = request.server.app.config;
if (!imageEditClient) {
imageEditClient = new HttpClient('imageEditClient', {
timeout: 5000,
connectionTimeout: 5000,
baseUrl: `${config.get('api.baseUrl')}`
});
}
request.log(['UploadImage payload coming from request'], request.payload);
let payload = request.payload;
let suffix = 'ImageUpload';
// let blob = new Blob([request.params.imageFile], {type: 'image/jpeg'});
let form = new FormData({maxDataSize: 20971520});
let form = new FormData({maxDataSize: 20971520});
const options = {
payload,
headers: {
'If-Match': '*',
'Content-Type': undefined
}
};
form.append('file', request.params.imageFile);
form.append('json', request.params.dataFile);
return imageEditClient.post(suffix, options, form).then(mutate)
.catch((err) => {
err.message = `ImageEditService: ${err.message} - ${suffix}.`;
throw err;
});
}
我收到以下错误:
[1] "value" must be a Function
[HAPIJS] at Object.exports.process (/Users/alnc/ha_projects/content-catalog-node-ui/node_modules/joi/lib/errors.js:181:19)
[HAPIJS] at iterate (/Users/alnc/ha_projects/content-catalog-node-ui/node_modules/items/lib/index.js:36:13)
[HAPIJS] [2018-09-03 09:20:51,836](53611) [log] [warn] - shutting down.
[HAPIJS] Debug: internal, implementation, error
[HAPIJS] ValidationError: Uncaught error: {
[HAPIJS] "_overheadLength": 206,
[HAPIJS] "_valueLength": 26,
[HAPIJS] "_valuesToMeasure": [],
[HAPIJS] "writable": false,
[HAPIJS] "readable": true,
[HAPIJS] "dataSize": 0,
[HAPIJS] "maxDataSize": 20971520,
[HAPIJS] "pauseStreams": true,
[HAPIJS] "_released": false,
[HAPIJS] "_streams": [
[HAPIJS] "----------------------------703740497184449347716405\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n",
[HAPIJS] "[object Blob]",
[HAPIJS] function () { [native code] },
[HAPIJS] "----------------------------703740497184449347716405\r\nContent-Disposition: form-data; name=\"json\"\r\n\r\n",
[HAPIJS] "[object Blob]",
[HAPIJS] function () { [native code] }
[HAPIJS] ],
[HAPIJS] "_currentStream": null,
[HAPIJS] "_boundary": "--------------------------703740497184449347716405",
[HAPIJS] "value" [1]: -- missing --
[HAPIJS] }
我不清楚这个错误。 有什么想法吗?
【问题讨论】:
标签: javascript reactjs redux react-redux jsx