Reputation: 1530
I am using the SSHJ library (https://github.com/shikhar/sshj).
I can use sshClient.newSCPFileTransfer();
to get my SCPClient
object, but then the call to scpClient.download()
requires either a String as the path for the destination file or a LocalDestFile object. All I want is to open a stream to download the file to. Is there a way to easily do this using SSHJ?
I looked at the different implementations of LocalDestFile, but nothing seemed applicable to this use case.
The specific use case is downloading a remote file and streaming it to a client's browser for a web app. I have to use SCP for this and thus want to use the SSHJ library.
Upvotes: 4
Views: 2717
Reputation: 1530
I was able to solve this by extending the InMemoryDestFile
class and passing my desired OutputStream
object into the constructor and having it returned in the getOutputStream
method.
An example is shown in the following GIST: https://gist.github.com/2157565
It seems that you need to close the OutputStream
on your own when you are done, so watch out for that.
Upvotes: 4