* Read the file from server
()
| 192 | * Read the file from server |
| 193 | */ |
| 194 | readFile() { |
| 195 | const filename = this.#path; |
| 196 | const localFilename = this.#getLocalname(filename); |
| 197 | return new Promise((resolve, reject) => { |
| 198 | sftp.isConnected((connectionID) => { |
| 199 | (async () => { |
| 200 | if (this.#notConnected(connectionID)) { |
| 201 | try { |
| 202 | await this.connect(); |
| 203 | } catch (error) { |
| 204 | reject(error); |
| 205 | return; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | sftp.getFile( |
| 210 | this.#safeName(filename), |
| 211 | localFilename, |
| 212 | async () => { |
| 213 | try { |
| 214 | const data = await internalFs.readFile(localFilename); |
| 215 | resolve(data); |
| 216 | } catch (error) { |
| 217 | reject(error); |
| 218 | } |
| 219 | }, |
| 220 | (err) => { |
| 221 | reject(err); |
| 222 | }, |
| 223 | ); |
| 224 | })(); |
| 225 | }); |
| 226 | }); |
| 227 | } |
| 228 | |
| 229 | async copyTo(dest) { |
| 230 | const src = this.#path; |
no test coverage detected