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
FieldsModifier and TypeFieldDescriptionprotected final Path
protected final ScpFileOpener
protected final Path
protected final Set
<PosixFilePermission> protected final long
protected final ScpTimestampCommandDetails
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.long
getSize()
resolveSourceStream
(Session session, long length, Set<PosixFilePermission> permissions, OpenOption... options) toString()
-
Field Details
-
path
-
opener
-
name
-
perms
-
size
protected final long size -
time
-
-
Constructor Details
-
LocalFileScpSourceStreamResolver
- Throws:
IOException
-
-
Method Details
-
getFileName
- Specified by:
getFileName
in interfaceScpSourceStreamResolver
- Returns:
- The uploaded file name
- Throws:
IOException
- If failed to resolve the name
-
getPermissions
- 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
- Specified by:
getTimestamp
in interfaceScpSourceStreamResolver
- Returns:
- The
ScpTimestampCommandDetails
to use for uploading the file ifnull
then no need to send this information - Throws:
IOException
- If failed to generate the required data
-
getSize
- 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
- 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.
-
toString
-