-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39769de
commit a4f242b
Showing
10 changed files
with
19,110 additions
and
18,788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Logger } from '@nestjs/common'; | ||
import { SftpClientService } from 'nest-sftp'; | ||
import { ConnectConfig } from 'ssh2'; | ||
|
||
export class SftpService { | ||
private readonly logger: Logger; | ||
constructor(private readonly sftpClient: SftpClientService) { | ||
this.logger = new Logger(); | ||
} | ||
|
||
async download( | ||
remotePath: string, | ||
localPath: string, | ||
): Promise<string | NodeJS.ReadableStream | Buffer> { | ||
return await this.sftpClient.download(remotePath, localPath) as unknown as Promise<string | NodeJS.ReadableStream | Buffer>; | ||
} | ||
|
||
// change connection to a different user/password prior to upload | ||
async submit( | ||
remotePath: string, | ||
localPath: string, | ||
submitConfig: ConnectConfig, | ||
): Promise<string | NodeJS.ReadableStream | Buffer> { | ||
await this.sftpClient.resetConnection(submitConfig); | ||
return await this.sftpClient.upload(remotePath, localPath); | ||
} | ||
} |
Oops, something went wrong.