Class LocalFileScpSourceStreamResolver
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.scp.helpers.LocalFileScpSourceStreamResolver
-
- All Implemented Interfaces:
ScpSourceStreamResolver
public class LocalFileScpSourceStreamResolver extends AbstractLoggingBean implements ScpSourceStreamResolver
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description protected Path
name
protected ScpFileOpener
opener
protected Path
path
protected Set<PosixFilePermission>
perms
protected long
size
protected ScpTimestamp
time
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description LocalFileScpSourceStreamResolver(Path path, ScpFileOpener opener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeSourceStream(Session session, long length, Set<PosixFilePermission> permissions, InputStream stream)
Called when the stream obtained fromresolveSourceStream
is no longer needed since since file copy was completed successfully.Path
getEventListenerFilePath()
String
getFileName()
Collection<PosixFilePermission>
getPermissions()
long
getSize()
ScpTimestamp
getTimestamp()
InputStream
resolveSourceStream(Session session, long length, Set<PosixFilePermission> permissions, OpenOption... options)
String
toString()
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
-
-
-
Field Detail
-
path
protected final Path path
-
opener
protected final ScpFileOpener opener
-
name
protected final Path name
-
perms
protected final Set<PosixFilePermission> perms
-
size
protected final long size
-
time
protected final ScpTimestamp time
-
-
Constructor Detail
-
LocalFileScpSourceStreamResolver
public LocalFileScpSourceStreamResolver(Path path, ScpFileOpener opener) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getFileName
public String getFileName() throws IOException
- Specified by:
getFileName
in interfaceScpSourceStreamResolver
- Returns:
- The uploaded file name
- Throws:
IOException
- If failed to resolve the name
-
getPermissions
public Collection<PosixFilePermission> getPermissions() throws IOException
- Specified by:
getPermissions
in interfaceScpSourceStreamResolver
- Returns:
- The permissions to be used for uploading a file
- Throws:
IOException
- If failed to generate the required permissions
-
getTimestamp
public ScpTimestamp getTimestamp() throws IOException
- Specified by:
getTimestamp
in interfaceScpSourceStreamResolver
- Returns:
- The
ScpTimestamp
to use for uploading the file ifnull
then no need to send this information - Throws:
IOException
- If failed to generate the required data
-
getSize
public long getSize() throws IOException
- Specified by:
getSize
in interfaceScpSourceStreamResolver
- Returns:
- An estimated size of the expected number of bytes to be uploaded. If non-positive then assumed to be unknown.
- Throws:
IOException
- If failed to generate an estimate
-
getEventListenerFilePath
public Path getEventListenerFilePath()
- Specified by:
getEventListenerFilePath
in interfaceScpSourceStreamResolver
- Returns:
- The
Path
to use when invoking theScpTransferEventListener
-
resolveSourceStream
public InputStream resolveSourceStream(Session session, long length, Set<PosixFilePermission> permissions, OpenOption... options) throws IOException
- Specified by:
resolveSourceStream
in interfaceScpSourceStreamResolver
- Parameters:
session
- TheSession
through which file is transmittedlength
- The expected transfer byte countpermissions
- The requested file permissionsoptions
- TheOpenOption
s may benull
/empty- Returns:
- The
InputStream
containing the data to be uploaded - Throws:
IOException
- If failed to create the stream
-
closeSourceStream
public void closeSourceStream(Session session, long length, Set<PosixFilePermission> permissions, InputStream stream) throws IOException
Description copied from interface:ScpSourceStreamResolver
Called when the stream obtained fromresolveSourceStream
is no longer needed since since file copy was completed successfully.- Specified by:
closeSourceStream
in interfaceScpSourceStreamResolver
- Parameters:
session
- TheSession
through which file is transmittedlength
- The expected transfer byte countpermissions
- The requested file permissionsstream
- TheInputStream
to close- Throws:
IOException
- If failed to close the stream - Note: stream will be closed regardless of whether this method throws an exception or not.
-
-