Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1020607 // dm_sendFileToOtherMachine - also splits. warning: signed, but not encrypted

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10972L/78K).

1  
static int dm_sendFileToOtherMachine_chunkSize = 100*1024; // 1024*1024;
2  
3  
svoid dm_sendFileToOtherMachine(File f, S computerID, S remotePath) {
4  
  dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon backupFile(
5  
    formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath))
6  
  ));
7  
  for (LongRange r : chunks(fileSize(f), dm_sendFileToOtherMachine_chunkSize)) {
8  
    print("Sending file chunk " + r + " of " + f + " to " + computerID + ":" + remotePath);
9  
    dm_evalOnOtherMachine(computerID,
10  
      formatFunctionCallWithSemicolon saveBinaryFilePart_base64(
11  
        formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)),
12  
        r.start + "L",
13  
        quote(base64encode(loadBinaryFileChunk(f, r)))));
14  
  }
15  
  dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon truncateFile(
16  
    formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)),
17  
    fileSize(f) + "L"));
18  
}
19  
20  
// works only for files under user dir. sends them to same path
21  
// in remote user dir.
22  
svoid dm_sendFileToOtherMachine(File f, S computerID) {
23  
  S path = assertNotNull(f2s(f) + " is not in " + userDir(), pathRelativeToUserDir(f));
24  
  dm_sendFileToOtherMachine(f, computerID, path);
25  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, jozkyjcghlvl, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020607
Snippet name: dm_sendFileToOtherMachine - also splits. warning: signed, but not encrypted
Eternal ID of this version: #1020607/12
Text MD5: 74500645e79ec270dbe4b06caa707f20
Transpilation MD5: 42889843c346852ab30fc1f310e761a3
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-17 00:41:37
Source code size: 1247 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 248 / 387
Version history: 11 change(s)
Referenced in: [show references]