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 AbstractLoggingBean implements ScpSourceStreamResolver
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.file.Pathnameprotected ScpFileOpeneropenerprotected java.nio.file.Pathpathprotected java.util.Set<java.nio.file.attribute.PosixFilePermission>permsprotected longsizeprotected ScpTimestampCommandDetailstime-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description LocalFileScpSourceStreamResolver(java.nio.file.Path path, ScpFileOpener opener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseSourceStream(Session session, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.io.InputStream stream)Called when the stream obtained fromresolveSourceStreamis no longer needed since since file copy was completed successfully.java.nio.file.PathgetEventListenerFilePath()java.lang.StringgetFileName()java.util.Collection<java.nio.file.attribute.PosixFilePermission>getPermissions()longgetSize()ScpTimestampCommandDetailsgetTimestamp()java.io.InputStreamresolveSourceStream(Session session, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.nio.file.OpenOption... options)java.lang.StringtoString()
-
-
-
Field Detail
-
path
protected final java.nio.file.Path path
-
opener
protected final ScpFileOpener opener
-
name
protected final java.nio.file.Path name
-
perms
protected final java.util.Set<java.nio.file.attribute.PosixFilePermission> perms
-
size
protected final long size
-
time
protected final ScpTimestampCommandDetails time
-
-
Constructor Detail
-
LocalFileScpSourceStreamResolver
public LocalFileScpSourceStreamResolver(java.nio.file.Path path, ScpFileOpener opener) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
getFileName
public java.lang.String getFileName() throws java.io.IOException- Specified by:
getFileNamein interfaceScpSourceStreamResolver- Returns:
- The uploaded file name
- Throws:
java.io.IOException- If failed to resolve the name
-
getPermissions
public java.util.Collection<java.nio.file.attribute.PosixFilePermission> getPermissions() throws java.io.IOException- Specified by:
getPermissionsin interfaceScpSourceStreamResolver- Returns:
- The permissions to be used for uploading a file
- Throws:
java.io.IOException- If failed to generate the required permissions
-
getTimestamp
public ScpTimestampCommandDetails getTimestamp() throws java.io.IOException
- Specified by:
getTimestampin interfaceScpSourceStreamResolver- Returns:
- The
ScpTimestampCommandDetailsto use for uploading the file ifnullthen no need to send this information - Throws:
java.io.IOException- If failed to generate the required data
-
getSize
public long getSize() throws java.io.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:
java.io.IOException- If failed to generate an estimate
-
getEventListenerFilePath
public java.nio.file.Path getEventListenerFilePath()
- Specified by:
getEventListenerFilePathin interfaceScpSourceStreamResolver- Returns:
- The
Pathto use when invoking theScpTransferEventListener
-
resolveSourceStream
public java.io.InputStream resolveSourceStream(Session session, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.nio.file.OpenOption... options) throws java.io.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:
java.io.IOException- If failed to create the stream
-
closeSourceStream
public void closeSourceStream(Session session, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.io.InputStream stream) throws java.io.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:
java.io.IOException- If failed to close the stream - Note: stream will be closed regardless of whether this method throws an exception or not.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-