public class SftpFileSystemProvider extends FileSystemProvider
FileSystemProvider that registers the "sftp://"
scheme so that URLs with this protocol are handled as remote SFTP Path-s
- e.g., "sftp://user:password@host/remote/file/path"| Modifier and Type | Field and Description |
|---|---|
static String |
AUTH_TIME_PROP_NAME |
static String |
CONNECT_TIME_PROP_NAME |
static long |
DEFAULT_AUTH_TIME |
static long |
DEFAULT_CONNECT_TIME |
static int |
DEFAULT_READ_BUFFER_SIZE |
static int |
DEFAULT_WRITE_BUFFER_SIZE |
protected org.slf4j.Logger |
log |
static String |
READ_BUFFER_PROP_NAME |
static Set<Class<? extends FileAttributeView>> |
UNIVERSAL_SUPPORTED_VIEWS |
static String |
VERSION_PARAM
URI parameter that can be used to specify a special version selection.
|
static String |
WRITE_BUFFER_PROP_NAME |
| Constructor and Description |
|---|
SftpFileSystemProvider() |
SftpFileSystemProvider(SftpVersionSelector selector) |
SftpFileSystemProvider(SshClient client) |
SftpFileSystemProvider(SshClient client,
SftpVersionSelector selector) |
createLink, deleteIfExists, installedProviders, newAsynchronousFileChannel, newFileSystem, newInputStream, newOutputStreampublic static final String READ_BUFFER_PROP_NAME
public static final int DEFAULT_READ_BUFFER_SIZE
public static final String WRITE_BUFFER_PROP_NAME
public static final int DEFAULT_WRITE_BUFFER_SIZE
public static final String CONNECT_TIME_PROP_NAME
public static final long DEFAULT_CONNECT_TIME
public static final String AUTH_TIME_PROP_NAME
public static final long DEFAULT_AUTH_TIME
public static final String VERSION_PARAM
URI parameter that can be used to specify a special version selection. Options are:
max - select maximum available version for the clientmin - select minimum available version for the clientcurrent - whatever version is reported by the servernnn - select only the specified versiona,b,c - select one of the specified versions (if available) in preference orderpublic static final Set<Class<? extends FileAttributeView>> UNIVERSAL_SUPPORTED_VIEWS
protected final org.slf4j.Logger log
public SftpFileSystemProvider()
public SftpFileSystemProvider(SftpVersionSelector selector)
public SftpFileSystemProvider(SshClient client)
client - The SshClient to use - if null then a
default one will be setup and started. Otherwise, it is assumed that
the client has already been startedSshClient.setUpDefaultClient()public SftpFileSystemProvider(SshClient client, SftpVersionSelector selector)
public String getScheme()
getScheme in class FileSystemProviderpublic final SftpVersionSelector getSftpVersionSelector()
public SftpFileSystem newFileSystem(URI uri, Map<String,?> env) throws IOException
newFileSystem in class FileSystemProviderIOExceptionprotected SftpVersionSelector resolveSftpVersionSelector(URI uri, SftpVersionSelector defaultSelector, PropertyResolver resolver)
public static Map<String,Object> resolveFileSystemParameters(Map<String,?> env, Map<String,Object> uriParams)
public SftpFileSystem newFileSystem(ClientSession session) throws IOException
IOExceptionpublic FileSystem getFileSystem(URI uri)
getFileSystem in class FileSystemProviderpublic SftpFileSystem removeFileSystem(String id)
id - File system identifier - ignored if null/emptySftpFileSystem - null if no matchpublic SftpFileSystem getFileSystem(String id)
id - File system identifier - ignored if null/emptySftpFileSystem - null if no matchpublic Path getPath(URI uri)
getPath in class FileSystemProviderpublic FileChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newByteChannel in class FileSystemProviderIOExceptionpublic FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newFileChannel in class FileSystemProviderIOExceptionpublic DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
newDirectoryStream in class FileSystemProviderIOExceptionpublic void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
createDirectory in class FileSystemProviderIOExceptionpublic void delete(Path path) throws IOException
delete in class FileSystemProviderIOExceptionpublic void copy(Path source, Path target, CopyOption... options) throws IOException
copy in class FileSystemProviderIOExceptionpublic void move(Path source, Path target, CopyOption... options) throws IOException
move in class FileSystemProviderIOExceptionpublic boolean isSameFile(Path path1, Path path2) throws IOException
isSameFile in class FileSystemProviderIOExceptionpublic boolean isHidden(Path path) throws IOException
isHidden in class FileSystemProviderIOExceptionpublic FileStore getFileStore(Path path) throws IOException
getFileStore in class FileSystemProviderIOExceptionpublic void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException
createSymbolicLink in class FileSystemProviderIOExceptionpublic Path readSymbolicLink(Path link) throws IOException
readSymbolicLink in class FileSystemProviderIOExceptionpublic void checkAccess(Path path, AccessMode... modes) throws IOException
checkAccess in class FileSystemProviderIOExceptionpublic <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
getFileAttributeView in class FileSystemProviderpublic boolean isSupportedFileAttributeView(Path path, Class<? extends FileAttributeView> type)
public boolean isSupportedFileAttributeView(SftpFileSystem fs, Class<? extends FileAttributeView> type)
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
readAttributes in class FileSystemProviderIOExceptionpublic Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException
readAttributes in class FileSystemProviderIOExceptionpublic Map<String,Object> readAttributes(Path path, String view, String attrs, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> readCustomViewAttributes(SftpPath path, String view, String attrs, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> readAclViewAttributes(SftpPath path, String view, String attrs, LinkOption... options) throws IOException
IOExceptionprotected SftpClient.Attributes readRemoteAttributes(SftpPath path, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> readPosixViewAttributes(SftpPath path, String view, String attrs, LinkOption... options) throws IOException
IOExceptionpublic void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
setAttribute in class FileSystemProviderIOExceptionpublic void setAttribute(Path path, String view, String attr, Object value, LinkOption... options) throws IOException
IOExceptionprotected int attributesToPermissions(Path path, Collection<PosixFilePermission> perms)
public static String getRWXPermissions(int perms)
public static String getOctalPermissions(int perms)
public static Set<PosixFilePermission> permissionsToAttributes(int perms)
public static String getOctalPermissions(Collection<PosixFilePermission> perms)
public static String getFileSystemIdentifier(URI uri)
uri - The URI - Note: not checked to make sure
that the scheme is sftp://getFileSystemIdentifier(String, int, String)public static String getFileSystemIdentifier(ClientSession session)
session - The ClientSessiongetFileSystemIdentifier(String, int, String)public static String getFileSystemIdentifier(String host, int port, String username)
public static URI createFileSystemURI(String host, int port, String username, String password)
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.