问题描述
我正在使用 lib 在 filezilla 服务器上加载几个文件。
尝试禁用被动模式,但没有任何变化。
我确定 close 被正确调用
这是 filezilla 服务器日志
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 230 Logged on
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> PWD
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 257 "/" is current directory.
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> EPRT |1|192.168.0.131|34809|
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 200 Port command successful
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> TYPE I
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 200 Type set to I
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> SIZE SR_START.001
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 550 File not found
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> EPRT |1|192.168.0.131|43235|
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 200 Port command successful
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> STOR SR_DATI.001
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 150 opening data channel for file upload to server of "/SR_DATI.001"
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 226 Successfully transferred "/SR_DATI.001"
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> EPRT |1|192.168.0.131|51689|
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 200 Port command successful
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> STOR SR_START.001
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 150 opening data channel for file upload to server of "/SR_START.001"
(000002)19/01/2021 17:08:22 - test (192.168.0.131)> 226 Successfully transferred "/SR_START.001"
(000002)19/01/2021 17:10:22 - test (192.168.0.131)> 421 Connection timed out.
(000002)19/01/2021 17:10:22 - test (192.168.0.131)> disconnected.
这是我的上传功能(我有一个类似的功能来检查是否存在调用 close 的文件)。
const uploadFile = ({ url,username,password }) => async (
srcPath,dstPath
) => {
let uploaded = false
const body = await fs.readFile(srcPath,'ascii')
const curl = new Curl()
curl.setopt('FTP_USE_EPSV',0)
curl.setopt('FTPPORT','-')
curl.setopt(Curl.option.URL,ftpProt(url) + dstPath)
curl.setopt(Curl.option.HTTPHEADER,[
'Content-Type: application/node-libcurl.raw'
])
curl.setopt('UPLOAD',1)
curl.setopt('READFUNCTION',targetBuffer => {
if (uploaded) {
return 0
}
targetBuffer.write(body)
uploaded = true
return body.length
})
curl.setopt('USERNAME',username)
curl.setopt('PASSWORD',password)
const res = new Promise(function (resolve,reject) {
curl.on('end',function (status,data) {
this.close()
status !== 226
? reject(Error(`Invalid status code: ${status}`))
: resolve(data)
})
curl.on('error',function (error) {
this.close()
reject(error)
})
})
curl.perform()
return res
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)