protected InputStream doGetInputStream() throws Exception
{
// VFS-113: avoid npe
synchronized (fileSystem)
{
final ChannelSftp channel = fileSystem.getChannel();
try
{
// return channel.get(getName().getPath());
// hmmm - using the in memory method is soooo much faster ...
// TODO - Don't read the entire file into memory. Use the
// stream-based methods on ChannelSftp once they work properly
/*
final ByteArrayOutputStream outstr = new ByteArrayOutputStream();
channel.get(relPath, outstr);
outstr.close();
return new ByteArrayInputStream(outstr.toByteArray());
*/
InputStream is;
try
{
// VFS-210: sftp allows to gather an input stream even from a directory and will
// fail on first read. So we need to check the type anyway
if (!getType().hasContent())
{
throw new FileSystemException("vfs.provider/read-not-file.error", getName());
}
is = channel.get(relPath);
}
catch (SftpException e)
{
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
{