trzsz / trzsz.js

trzsz.js is the js version of trzsz, makes terminal built with electron and webshell to support trzsz ( trz / tsz ).
https://trzsz.github.io/js
MIT License
189 stars 12 forks source link

chooseSaveDirectory is not a function #4

Closed fullee closed 2 years ago

fullee commented 2 years ago
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/trzsz/svr/send.py", line 73, in main
    action = recv_action()
  File "/usr/local/lib/python3.6/site-packages/trzsz/libs/utils.py", line 318, in recv_action
    return recv_json('ACT')
  File "/usr/local/lib/python3.6/site-packages/trzsz/libs/utils.py", line 307, in recv_json
    dic = recv_string(typ, may_has_junk)
  File "/usr/local/lib/python3.6/site-packages/trzsz/libs/utils.py", line 233, in recv_string
    return decode_buffer(recv_check(typ, may_has_junk)).decode('utf8')
  File "/usr/local/lib/python3.6/site-packages/trzsz/libs/utils.py", line 213, in recv_check
    raise TrzszError(buf, typ)
trzsz.libs.utils.TrzszError: TypeError: this.chooseSaveDirectory is not a function
    at t2.<anonymous> (http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:2655:29)
    at http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:109:21
    at Object.next (http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:118:8)
    at http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:55:38
    at new Promise (<anonymous>)
    at e (http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:34:10)
    at t2.handleTrzszDownloadFiles (http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:2648:12)
    at t2.<anonymous> (http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:2621:131)
    at http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:109:21
    at Object.next (http://localhost:3000/node_modules/.vite/deps/trzsz.js?v=a7c740da:118:8)
lonnywong commented 2 years ago

It's running with Node.js environment. You need to implement the two functions.

const trzszFilter = new TrzszFilter({
  // call on the user runs trz ( upload files ) on the server and no error on require('fs').
  chooseSendFiles: async () => {
    // return `undefined` if the user cancels.
    // return an array of file paths choosed by the user.
    return ["/path/to/file1", "/path/to/file2"];
  },
  // call on the user runs tsz ( download files ) on the server and no error on require('fs').
  chooseSaveDirectory: async () => {
    // return `undefined` if the user cancels.
    // return a directory path choosed by the user.
    return "/path/to/directory";
  },
});
fullee commented 2 years ago

i used xterm.js join trzsz by TrzszAddon @lonnywong image

lonnywong commented 2 years ago

i used xterm.js join trzsz by TrzszAddon

You can implement chooseSendFiles and chooseSaveDirectory too.

const trzszAddon = new TrzszAddon(webSocket, {
  // call on the user runs trz ( upload files ) on the server and no error on require('fs').
  chooseSendFiles: async () => {
    // return `undefined` if the user cancels.
    // return an array of file paths choosed by the user.
    return ["/path/to/file1", "/path/to/file2"];
  },
  // call on the user runs tsz ( download files ) on the server and no error on require('fs').
  chooseSaveDirectory: async () => {
    // return `undefined` if the user cancels.
    // return a directory path choosed by the user.
    return "/path/to/directory";
  },
});