nodejs sftp.与编码一起呼叫

发布于 2025-02-13 18:01:40 字数 932 浏览 1 评论 0原文

我正在使用node.js的ssh2-sftp-client软件包。 我正在尝试进行SFTP调用,以获取具有特定编码的文件。 当我不使用任何编码时,我可以获取文件:

var config = {
        host: urls,
        port: port,
        user: user,
        password: password,
      };
let sftp = new Client;
sftp.connect(config).then(() => {
sftp.get(file)
.then((response) => {My Code});
}

编码不正确。 根据文档该文件将到达:

sftp.get(remoteFilePath, [useCompression], [encoding], [addtionalOptions]);

当我尝试添加编码时:

sftp.get(file,[false],["iso-8859-1"])

我会收到一个错误消息:

wtr.once('error', (err) => {
              ^
TypeError: wtr.once is not a function

我尝试在没有数组括号的情况下添加:

sftp.get(file,false,"iso-8859-1")

但这也不起作用。

打电话时,如何指定文件的编码?

谢谢

I am using the ssh2-sftp-client package for Node.js.
I am trying to make an sftp call to get a file with a specific encoding.
I am able to get the file when I do not use any encoding:

var config = {
        host: urls,
        port: port,
        user: user,
        password: password,
      };
let sftp = new Client;
sftp.connect(config).then(() => {
sftp.get(file)
.then((response) => {My Code});
}

The encoding is incorrect.
According to the documentation, I can specify the encoding the file will arrive in:

sftp.get(remoteFilePath, [useCompression], [encoding], [addtionalOptions]);

When I try to add the encoding:

sftp.get(file,[false],["iso-8859-1"])

I get an error message:

wtr.once('error', (err) => {
              ^
TypeError: wtr.once is not a function

I tried to add without the array brackets:

sftp.get(file,false,"iso-8859-1")

But that doesn't work either.

How can I specify the encoding of the file when I make the call?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文