我正在尝试使用multer-ftp通过nodeJS和multer上传文件,我可以做到,但是在此之后我一直遇到错误,因为我没有关闭连接。我想知道如何做到这一点。
const FTPStorage = require('multer-ftp')
const upload2 = multer({
storage: new FTPStorage({
basepath: '/',
ftp: {
host: process.env.BP_RESALE_CERT_HOST,
port: process.env.BP_RESALE_CERT_PORT,
user: process.env.BP_RESALE_CERT_USER,
password: process.env.BP_RESALE_CERT_PASSWORD
},
destination: function (req, file, options, callback) {
console.log(req.file);
console.log(file);
callback(null, req.file.originalname) // custom file destination, file extension is added to the end of the path
},
})
}).single('file');
这是我记录的内容,我不知道如何在示例代码中添加关闭它。
Error: No-transfer-time exceeded. Closing control connection.
at makeError (/var/www/backend/node_modules/ftp/lib/connection.js:1067:13)
at Parser.<anonymous> (/var/www/backend/node_modules/ftp/lib/connection.js:115:28)
at Parser.emit (events.js:182:13)
at Parser._write (/var/www/natco-backend/node_modules/ftp/lib/parser.js:59:10)
at doWrite (_stream_writable.js:410:12)
at writeOrBuffer (_stream_writable.js:394:5)
at Parser.Writable.write (_stream_writable.js:294:11)
at Socket.ondata (/var/www/natco-backend/node_modules/ftp/lib/connection.js:273:20)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)