[GH-ISSUE #2563] feat: Support drop folder to upload with trz #1657

Open
opened 2026-02-27 00:04:22 +03:00 by kerem · 0 comments
Owner

Originally created by @zxdong262 on GitHub (Jul 14, 2022).
Original GitHub issue: https://github.com/electerm/electerm/issues/2563

@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 事件,注意上传文件时不要将文件路径输出给服务器,要不然可能会导致上传失败。

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

Originally posted by @lonnywong in https://github.com/electerm/electerm/issues/2559#issuecomment-1179701493

Originally created by @zxdong262 on GitHub (Jul 14, 2022). Original GitHub issue: https://github.com/electerm/electerm/issues/2563 @zxdong262 [trzsz.js](https://github.com/trzsz/trzsz.js) `v0.4.0` 开始支持拖文件和目录上传的了。 1、在服务器上安装 [trzsz](https://github.com/trzsz/trzsz) 或者 [trzsz-go](https://github.com/trzsz/trzsz-go),只要在某个 `PATH` 路径下能找到 `trz` 程序就可以了。 2、客户端监听 `drop` 事件,然后调用 `trzsz` 的 `uploadFiles` 接口就可以了。 https://github.com/electerm/electerm/blob/master/src/client/components/terminal/attach-addon-custom.js 这里面有一个 `const trzsz = window.newTrzsz(...)` ,调 `trzsz` 对象的 `uploadFiles` 函数即可。 ```js terminalHtmlElement.addEventListener("drop", (event) => { event.preventDefault(); trzsz .uploadFiles(event.dataTransfer.items) .then(() => console.log("upload success")) .catch((err) => console.log(err)); }); ``` 我看到应该有监听 `onDrop` 事件,注意上传文件时不要将文件路径输出给服务器,要不然可能会导致上传失败。 对我来说有点复杂了,所以我没实现。如果你计划实现这个功能,建议搞一个是否启用的配置项。 _Originally posted by @lonnywong in https://github.com/electerm/electerm/issues/2559#issuecomment-1179701493_
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/electerm#1657
No description provided.