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.Path
name
protected ScpFileOpener
opener
protected java.nio.file.Path
path
protected java.util.Set<java.nio.file.attribute.PosixFilePermission>
perms
protected long
size
protected ScpTimestampCommandDetails
time
-
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 void
closeSourceStream(Session session, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.io.InputStream stream)
Called when the stream obtained fromresolveSourceStream
is no longer needed since since file copy was completed successfully.java.nio.file.Path
getEventListenerFilePath()
java.lang.String
getFileName()
java.util.Collection<java.nio.file.attribute.PosixFilePermission>
getPermissions()
long
getSize()
ScpTimestampCommandDetails
getTimestamp()
java.io.InputStream
resolveSourceStream(Session session, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.nio.file.OpenOption... options)
java.lang.String
toString()
-
-
-
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:
getFileName
in 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:
getPermissions
in 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:
getTimestamp
in interfaceScpSourceStreamResolver
- Returns:
- The
ScpTimestampCommandDetails
to use for uploading the file ifnull
then 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:
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:
java.io.IOException
- If failed to generate an estimate
-
getEventListenerFilePath
public java.nio.file.Path getEventListenerFilePath()
- Specified by:
getEventListenerFilePath
in interfaceScpSourceStreamResolver
- Returns:
- The
Path
to 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:
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:
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: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:
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:
toString
in classjava.lang.Object
-
-