Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trzsz ( trz / tsz ) supports directories #2559

Merged
merged 2 commits into from
Jul 12, 2022
Merged

Conversation

lonnywong
Copy link
Contributor

@lonnywong lonnywong commented Jul 10, 2022

  1. supports directories, trz -d, tsz -d dir
  2. supports windows local shell

@lonnywong
Copy link
Contributor Author

@zxdong262

trzsz.js v0.4.0 开始支持拖文件和目录上传的了。

1、在服务器上安装 trzsz 或者 trzsz-go,只要在某个 PATH 路径下能找到 trz 程序就可以了。

2、客户端监听 drop 事件,然后调用 trzszuploadFiles 接口就可以了。

https://github.com/electerm/electerm/blob/master/src/client/components/terminal/attach-addon-custom.js
这里面有一个 const trzsz = window.newTrzsz(...) ,调 trzsz 对象的 uploadFiles 函数即可。

terminalHtmlElement.addEventListener("drop", (event) => {
  event.preventDefault();
  trzsz
    .uploadFiles(event.dataTransfer.items)
    .then(() => console.log("upload success"))
    .catch((err) => console.log(err));
});

我看到应该有监听 onDrop 事件,注意上传文件时不要将文件路径输出给服务器,要不然可能会导致上传失败。

对我来说有点复杂了,所以我没实现。如果你计划实现这个功能,建议搞一个是否启用的配置项。

@zxdong262 zxdong262 merged commit ee9012c into electerm:master Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants