Class LocalFileScpSourceStreamResolver
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.scp.common.helpers.LocalFileScpSourceStreamResolver
-
- All Implemented Interfaces:
ScpSourceStreamResolver
public class LocalFileScpSourceStreamResolver extends org.apache.sshd.common.util.logging.AbstractLoggingBean implements ScpSourceStreamResolver
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description protected Pathnameprotected ScpFileOpeneropenerprotected Pathpathprotected Set<PosixFilePermission>permsprotected longsizeprotected ScpTimestampCommandDetailstime
-
Constructor Summary
Constructors Constructor Description LocalFileScpSourceStreamResolver(Path path, ScpFileOpener opener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseSourceStream(Session session, long length, Set<PosixFilePermission> permissions, InputStream stream)Called when the stream obtained fromresolveSourceStreamis no longer needed since since file copy was completed successfully.PathgetEventListenerFilePath()StringgetFileName()Collection<PosixFilePermission>getPermissions()longgetSize()ScpTimestampCommandDetailsgetTimestamp()InputStreamresolveSourceStream(Session session, long length, Set<PosixFilePermission> permissions, OpenOption... options)StringtoString()
-
-
-
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 ScpTimestampCommandDetails time
-
-
Constructor Detail
-
LocalFileScpSourceStreamResolver
public LocalFileScpSourceStreamResolver(Path path, ScpFileOpener opener) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getFileName
public String getFileName() throws IOException
- Specified by:
getFileNamein interfaceScpSourceStreamResolver- Returns:
- The uploaded file name
- Throws:
IOException- If failed to resolve the name
-
getPermissions
public Collection<PosixFilePermission> getPermissions() throws IOException
- Specified by:
getPermissionsin interfaceScpSourceStreamResolver- Returns:
- The permissions to be used for uploading a file
- Throws:
IOException- If failed to generate the required permissions
-
getTimestamp
public ScpTimestampCommandDetails getTimestamp() throws IOException
- Specified by:
getTimestampin interfaceScpSourceStreamResolver- Returns:
- The
ScpTimestampCommandDetailsto use for uploading the file ifnullthen no need to send this information - Throws:
IOException- If failed to generate the required data
-
getSize
public long getSize() throws IOException- Specified by:
getSizein 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:
getEventListenerFilePathin interfaceScpSourceStreamResolver- Returns:
- The
Pathto use when invoking theScpTransferEventListener
-
resolveSourceStream
public InputStream resolveSourceStream(Session session, long length, Set<PosixFilePermission> permissions, OpenOption... options) throws IOException
- Specified by:
resolveSourceStreamin interfaceScpSourceStreamResolver- Parameters:
session- TheSessionthrough which file is transmittedlength- The expected transfer byte countpermissions- The requested file permissionsoptions- TheOpenOptions may benull/empty- Returns:
- The
InputStreamcontaining 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:ScpSourceStreamResolverCalled when the stream obtained fromresolveSourceStreamis no longer needed since since file copy was completed successfully.- Specified by:
closeSourceStreamin interfaceScpSourceStreamResolver- Parameters:
session- TheSessionthrough which file is transmittedlength- The expected transfer byte countpermissions- The requested file permissionsstream- TheInputStreamto close- Throws:
IOException- If failed to close the stream - Note: stream will be closed regardless of whether this method throws an exception or not.
-
-