MCPcopy Create free account
hub / github.com/electerm/electerm / readRemoteFile

Function readRemoteFile

src/app/server/ftp-file.js:3–17  ·  view source on GitHub ↗
(client, remotePath)

Source from the content-addressed store, hash-verified

1const { Readable, Writable } = require('stream')
2
3async function readRemoteFile (client, remotePath) {
4 return new Promise((resolve, reject) => {
5 let data = ''
6 const writable = new Writable({
7 write (chunk, encoding, callback) {
8 data += chunk.toString()
9 callback()
10 }
11 })
12
13 client.downloadTo(writable, remotePath)
14 .then(() => resolve(data))
15 .catch(reject)
16 })
17}
18
19async function writeRemoteFile (client, remotePath, str) {
20 const readable = new Readable({

Callers 2

readFileMethod · 0.70
readFileMethod · 0.70

Calls 2

resolveFunction · 0.85
downloadToMethod · 0.80

Tested by

no test coverage detected