I just found VFS as a way to access sftp. Seems to work but all the examples assume a local file; instead I have my data in memory. I only see a method copyFrom(FileObject), no overloads accepting a stream or a buffer... So I tried ram as it sounds approximately right (some documentation wouldn't hurt but I can't fine any) and the following test succeeds. Copying into an sftp FileObject also worked.
QUESTION. It gives the following output: INFO: Using "C:\Users\myname\AppData\Local\Temp\vfs_cache" as temporary files store.
-- is it actually writing a temp file?? That's what I was trying to avoid (due to potential permissions/concurrency problems on the Unix servers where this thing will run). If it does, how do I do it completely in-memory?
// try to copy a string from memory into a FileObject
public class VFSTest {
public static void main(String[] args) throws IOException {
String hello = "Hello, World!";
FileObject ram = VFS.getManager().resolveFile("ram:/tmp");
OutputStream os = ram.getContent().getOutputStream();
os.write(hello.getBytes());
ram.getContent().close();
FileObject local = VFS.getManager().resolveFile("C:\\foo.txt");
local.copyFrom(ram, Selectors.SELECT_SELF);
}
}