dreambigcoder
dreambigcoder

Reputation: 1907

transfer file from GCS bucket to SFTP server in java

I am able to read files from GCS bucket, but all the libraries like jsch which does file transfer to SFTP server look for a file path, instead of the file in memory. I don't want to write the file I read from GCS to a disk, How do I transfer the file in memory to SFTP?

Upvotes: 0

Views: 389

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202138

I assume you want to upload in-memory data. JSch actually has loads of ChannelSftp.put methods overloads that can upload in-memory data.

The basic one is with use of InputStream:

public void put(InputStream src, String dst) throws SftpException

The other options is with use of OutputStream:

public OutputStream put(String dst) throws SftpException

Upvotes: 1

Related Questions