环回组件存储文件上传请求中止 formidable\lib\incoming_form.js
loopback component storage file upload request aborted formidable\lib\incoming_form.js
我已经成功配置了环回的存储组件,即环回组件存储。我已经能够创建文件夹。但是当我尝试上传文件(使用邮递员)时,它一直给出请求中止错误:
error: Error: Request aborted
at IncomingMessage.<anonymous> (E:\projects\TestProject\node_modules\formidable\lib\incoming_form.js:120:19)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at abortIncoming (_http_server.js:283:11)
at TLSSocket.serverSocketCloseListener (_http_server.js:296:5)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:188:7)
at _handle.close (net.js:498:12)
at Socket.done (_tls_wrap.js:325:7)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:498:12)
我还配置了 SSL,所以 url 是 https://localhost/api/containers/container1/upload。这可能是个问题吗?我在 package.json.
中使用了以下模块
"dependencies": {
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.1",
"express": "^4.15.2",
"helmet": "^3.4.1",
"js2xmlparser": "^3.0.0",
"loopback": "^3.4.0",
"loopback-boot": "^2.23.0",
"loopback-component-explorer": "^4.1.1",
"loopback-component-storage": "^3.2.0",
"loopback-connector-rest": "^2.1.0",
"loopback-datasource-juggler": "^3.2.0",
"loopback-ssl": "0.0.9",
"multer": "^1.3.0",
"strong-error-handler": "^2.1.0",
"winston": "^2.3.1"
}
server.js 文件如下所示:
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var loopbackSSL = require('loopback-ssl');
var bodyParser = require('body-parser');
var multer = require('multer');
var app = module.exports = loopback();
app.use(bodyParser.text());
app.start = function () {
// start the web server
return app.listen(function () {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function (err) {
if (err) throw err;
if (require.main === module)
return loopbackSSL.startServer(app);
});
以上任何一个模块都会有问题吗?看起来这是一个节点棘手的问题。谁能告诉我?我们可以编写一个远程方法来接受文件吗?
我已经通过删除
解决了这个问题
app.use(bodyParser.text());
来自 server.js。正在上传文件。
想为其他观众发表评论(但我没有足够的声誉),因为我遇到了类似的问题并删除了以下对我有用的内容:
app.use(multer({storage: storage}).any())
感谢您发布这个和您找到的解决方案,我的解决方案几乎相同。
我已经成功配置了环回的存储组件,即环回组件存储。我已经能够创建文件夹。但是当我尝试上传文件(使用邮递员)时,它一直给出请求中止错误:
error: Error: Request aborted
at IncomingMessage.<anonymous> (E:\projects\TestProject\node_modules\formidable\lib\incoming_form.js:120:19)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at abortIncoming (_http_server.js:283:11)
at TLSSocket.serverSocketCloseListener (_http_server.js:296:5)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:188:7)
at _handle.close (net.js:498:12)
at Socket.done (_tls_wrap.js:325:7)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:498:12)
我还配置了 SSL,所以 url 是 https://localhost/api/containers/container1/upload。这可能是个问题吗?我在 package.json.
中使用了以下模块 "dependencies": {
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.1",
"express": "^4.15.2",
"helmet": "^3.4.1",
"js2xmlparser": "^3.0.0",
"loopback": "^3.4.0",
"loopback-boot": "^2.23.0",
"loopback-component-explorer": "^4.1.1",
"loopback-component-storage": "^3.2.0",
"loopback-connector-rest": "^2.1.0",
"loopback-datasource-juggler": "^3.2.0",
"loopback-ssl": "0.0.9",
"multer": "^1.3.0",
"strong-error-handler": "^2.1.0",
"winston": "^2.3.1"
}
server.js 文件如下所示:
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var loopbackSSL = require('loopback-ssl');
var bodyParser = require('body-parser');
var multer = require('multer');
var app = module.exports = loopback();
app.use(bodyParser.text());
app.start = function () {
// start the web server
return app.listen(function () {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function (err) {
if (err) throw err;
if (require.main === module)
return loopbackSSL.startServer(app);
});
以上任何一个模块都会有问题吗?看起来这是一个节点棘手的问题。谁能告诉我?我们可以编写一个远程方法来接受文件吗?
我已经通过删除
解决了这个问题app.use(bodyParser.text());
来自 server.js。正在上传文件。
想为其他观众发表评论(但我没有足够的声誉),因为我遇到了类似的问题并删除了以下对我有用的内容:
app.use(multer({storage: storage}).any())
感谢您发布这个和您找到的解决方案,我的解决方案几乎相同。