public final class CloudStorageFileSystem extends FileSystem
Static Fields
BASIC_VIEW
public static final String BASIC_VIEW
Field Value
BLOCK_SIZE_DEFAULT
public static final int BLOCK_SIZE_DEFAULT
Field Value
FILE_TIME_UNKNOWN
public static final FileTime FILE_TIME_UNKNOWN
Field Value
GCS_VIEW
public static final String GCS_VIEW
Field Value
SUPPORTED_VIEWS
public static final Set<String> SUPPORTED_VIEWS
Field Value
URI_SCHEME
public static final String URI_SCHEME
Field Value
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
Returns
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)
Parameters
Returns
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)
Parameters
Returns
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.
Returns
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
Exceptions
config()
public CloudStorageConfiguration config()
Returns configuration object for this file system instance.
Returns
equals(Object other)
public boolean equals(Object other)
Parameter
Returns
Overrides
getFileStores()
public Iterable<FileStore> getFileStores()
Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or
anything similar.
Returns
Overrides
getPath(String first, String[] more)
public CloudStoragePath getPath(String first, String[] more)
Converts Cloud Storage object name to a Path object.
Parameters
Returns
Overrides
getPathMatcher(String syntaxAndPattern)
public PathMatcher getPathMatcher(String syntaxAndPattern)
Parameter
Name | Description |
syntaxAndPattern | String
|
Returns
Overrides
getRootDirectories()
public Iterable<Path> getRootDirectories()
Returns
Overrides
getSeparator()
public String getSeparator()
Returns {@value UnixPath#SEPARATOR}.
Returns
Overrides
getUserPrincipalLookupService()
public UserPrincipalLookupService getUserPrincipalLookupService()
Returns
Overrides
hashCode()
Returns
Overrides
isOpen()
Returns true
, even if you previously called the #close() method.
Returns
Overrides
isReadOnly()
public boolean isReadOnly()
Returns
Overrides
newWatchService()
public WatchService newWatchService()
Returns
Overrides
Exceptions
provider()
public CloudStorageFileSystemProvider provider()
Returns
Overrides
supportedFileAttributeViews()
public Set<String> supportedFileAttributeViews()
Returns
Overrides
toString()
Returns
Overrides