1 | import net.schmizz.sshj.xfer.InMemorySourceFile; |
2 | import net.schmizz.sshj.xfer.scp.SCPFileTransfer; |
3 | |
4 | // allow any host ID and search for pw in JavaX-Secret |
5 | static void scpUploadWithMkdirs(S user, S host, fS remotePath, final long length, final InputStream in) ctex { |
6 | final SSHClient client = sshLogin(user, host); |
7 | print("Logged in to SSH server " + user + "@" + host); |
8 | try { |
9 | S remoteDir = dropAfterLastSlash(remotePath); |
10 | if (nempty(remoteDir)) |
11 | client.newSFTPClient().mkdirs(remoteDir); |
12 | print("Uploading to on " + user + "@" + host + ": " + remotePath); |
13 | SCPFileTransfer fileTransfer = client.newSCPFileTransfer(); |
14 | fileTransfer.upload(new InMemorySourceFile { |
15 | public S getName() { ret "dummy"; } |
16 | public long getLength() { ret length; } |
17 | public InputStream getInputStream() { ret in; } |
18 | }, remotePath); |
19 | } finally { |
20 | sshDisconnect(client); |
21 | } |
22 | } |
Began life as a copy of #1009981
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009983 |
Snippet name: | scpUploadWithMkdirs |
Eternal ID of this version: | #1009983/6 |
Text MD5: | 2c74cf7c92bc2962f594a08627e97d6f |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-24 03:08:23 |
Source code size: | 920 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 445 / 489 |
Version history: | 5 change(s) |
Referenced in: | [show references] |