public final class CloudStorageFileSystem extends FileSystem
Static Fields
BASIC_VIEW
public static final String BASIC_VIEW
Field Value |
---|
Type | Description |
String | |
BLOCK_SIZE_DEFAULT
public static final int BLOCK_SIZE_DEFAULT
Field Value |
---|
Type | Description |
int | |
FILE_TIME_UNKNOWN
public static final FileTime FILE_TIME_UNKNOWN
GCS_VIEW
public static final String GCS_VIEW
Field Value |
---|
Type | Description |
String | |
POSIX_VIEW
public static final String POSIX_VIEW
Field Value |
---|
Type | Description |
String | |
SUPPORTED_VIEWS
public static final Set<String> SUPPORTED_VIEWS
URI_SCHEME
public static final String URI_SCHEME
Field Value |
---|
Type | Description |
String | |
Static Methods
forBucket(String bucket)
public static CloudStorageFileSystem forBucket(String bucket)
Returns Google Cloud Storage FileSystem object for bucket
.
NOTE: You may prefer to use Java's standard API instead:
FileSystem fs = FileSystems.getFileSystem(URI.create("gs://bucket"));
However some systems and build environments might be flaky when it comes to Java SPI. This
is because services are generally runtime dependencies and depend on a META-INF file being
present in your jar (generated by Google Auto at compile-time). In such cases, this method
provides a simpler alternative.
See Also: #forBucket(String, CloudStorageConfiguration), java.nio.file.FileSystems#getFileSystem(java.net.URI)
Parameter |
---|
Name | Description |
bucket | String
|
forBucket(String bucket, CloudStorageConfiguration config)
public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config)
Creates new file system instance for bucket
, with customizable settings.
See Also: #forBucket(String)
forBucket(String bucket, CloudStorageConfiguration config, StorageOptions storageOptions)
public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config, StorageOptions storageOptions)
Returns Google Cloud Storage FileSystem object for bucket
.
Google Cloud Storage file system objects are basically free. You can create as many as you
want, even if you have multiple instances for the same bucket. There's no actual system
resources associated with this object. Therefore calling #close() on the returned value
is optional.
Note: It is also possible to instantiate this class via Java's
FileSystems.getFileSystem(URI.create("gs://bucket"))
. We discourage you from using that if
possible, for the reasons documented in CloudStorageFileSystemProvider#newFileSystem(URI, java.util.Map)
See Also: java.nio.file.FileSystems#getFileSystem(URI)
listBuckets(String project, Storage.BucketListOption[] options)
public static Page<Bucket> listBuckets(String project, Storage.BucketListOption[] options)
Lists the project's buckets. Pass "null" to use the default project.
Example of listing buckets, specifying the page size and a name prefix.
String prefix = "bucket_";
Page<Bucket> buckets = CloudStorageFileSystem.listBuckets("my-project", BucketListOption.prefix(prefix));
Iterator<Bucket> bucketIterator = buckets.iterateAll();
while (bucketIterator.hasNext()) {
Bucket bucket = bucketIterator.next();
// do something with the bucket
}
Parameters |
---|
Name | Description |
project | String
|
options | com.google.cloud.storage.Storage.BucketListOption[]
|
Returns |
---|
Type | Description |
Page<com.google.cloud.storage.Bucket> | |
Methods
bucket()
Returns Cloud Storage bucket name being served by this file system.
close()
Does nothing currently. This method might be updated in the future to close all channels
associated with this file system object. However it's unlikely that even then, calling this
method will become mandatory.
Overrides
config()
public CloudStorageConfiguration config()
Returns configuration object for this file system instance.
equals(Object other)
public boolean equals(Object other)
Parameter |
---|
Name | Description |
other | Object
|
Overrides
getFileStores()
public Iterable<FileStore> getFileStores()
Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or
anything similar.
Overrides
getPath(String first, String[] more)
public CloudStoragePath getPath(String first, String[] more)
Converts Cloud Storage object name to a Path object.
Overrides
getPathMatcher(String syntaxAndPattern)
public PathMatcher getPathMatcher(String syntaxAndPattern)
Parameter |
---|
Name | Description |
syntaxAndPattern | String
|
Overrides
getRootDirectories()
public Iterable<Path> getRootDirectories()
Overrides
getSeparator()
public String getSeparator()
Returns {@value UnixPath#SEPARATOR}.
Overrides
getUserPrincipalLookupService()
public UserPrincipalLookupService getUserPrincipalLookupService()
Overrides
hashCode()
Returns |
---|
Type | Description |
int | |
Overrides
isOpen()
Returns true
, even if you previously called the #close() method.
Overrides
isReadOnly()
public boolean isReadOnly()
Overrides
newWatchService()
public WatchService newWatchService()
Overrides
provider()
public CloudStorageFileSystemProvider provider()
Overrides
supportedFileAttributeViews()
public Set<String> supportedFileAttributeViews()
Overrides
toString()
Overrides