I am getting inputstream from the Jsch channelSFTP like below.
ChannelSftp channelSftp = (ChannelSftp) channel;
InputStream input = channelsftp.get(unixPath); // unixPath is path to my file which is on SFTP server
I have to attach the file in the unixPath in the Spring JavaMail attachment. But when I see API of Spring JavaMail addAttachment() method it takes only InputStreamSource or Datasource.
My problem is I am not able to get the InputStreamSource or Datasource from the inputStream which I am getting form SFTP channel.
How Can I get InputStreamSource or Datasource from the above InputStream?
From the documentation,
InputStreamSourceis an interface. One of its implementations isInputStreamResource, which has a constructor that takes in anInputStream. Here is the JavaDoc for it.You should be able to setup your call as such: