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).

static int dm_sendFileToOtherMachine_chunkSize = 100*1024; // 1024*1024;

svoid dm_sendFileToOtherMachine(File f, S computerID, S remotePath) {
  dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon backupFile(
    formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath))
  ));
  for (LongRange r : chunks(fileSize(f), dm_sendFileToOtherMachine_chunkSize)) {
    print("Sending file chunk " + r + " of " + f + " to " + computerID + ":" + remotePath);
    dm_evalOnOtherMachine(computerID,
      formatFunctionCallWithSemicolon saveBinaryFilePart_base64(
        formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)),
        r.start + "L",
        quote(base64encode(loadBinaryFileChunk(f, r)))));
  }
  dm_evalOnOtherMachine(computerID, formatFunctionCallWithSemicolon truncateFile(
    formatFunctionCall fileRelativeToUserDirUnlessAbsolute(quote(remotePath)),
    fileSize(f) + "L"));
}

// works only for files under user dir. sends them to same path
// in remote user dir.
svoid dm_sendFileToOtherMachine(File f, S computerID) {
  S path = assertNotNull(f2s(f) + " is not in " + userDir(), pathRelativeToUserDir(f));
  dm_sendFileToOtherMachine(f, computerID, path);
}

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: 353 / 517
Version history: 11 change(s)
Referenced in: [show references]