Class CloudStorageFileSystem
- All Implemented Interfaces:
Closeable,AutoCloseable
FileSystem implementation.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbucket()Returns Cloud Storage bucket name being served by this file system.voidclose()Does nothing currently.config()Returns configuration object for this file system instance.booleanstatic CloudStorageFileSystemReturns Google Cloud StorageFileSystemobject forbucket.static CloudStorageFileSystemforBucket(String bucket, CloudStorageConfiguration config) Creates new file system instance forbucket, with customizable settings.static CloudStorageFileSystemforBucket(String bucket, CloudStorageConfiguration config, com.google.cloud.storage.StorageOptions storageOptions) Returns Google Cloud StorageFileSystemobject forbucket.Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or anything similar.Converts Cloud Storage object name to aPathobject.getPathMatcher(String syntaxAndPattern) Returns '/'.ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet.inthashCode()booleanisOpen()Returnstrue, even if you previously called theclose()method.booleanReturnsfalse.static com.google.api.gax.paging.Page<com.google.cloud.storage.Bucket>listBuckets(String project, com.google.cloud.storage.Storage.BucketListOption... options) Lists the project's buckets.ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet.provider()toString()
-
Field Details
-
URI_SCHEME
- See Also:
-
GCS_VIEW
- See Also:
-
BASIC_VIEW
- See Also:
-
POSIX_VIEW
- See Also:
-
BLOCK_SIZE_DEFAULT
public static final int BLOCK_SIZE_DEFAULT- See Also:
-
FILE_TIME_UNKNOWN
-
SUPPORTED_VIEWS
-
-
Method Details
-
listBuckets
public static com.google.api.gax.paging.Page<com.google.cloud.storage.Bucket> listBuckets(@Nullable String project, com.google.cloud.storage.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 }- Throws:
com.google.cloud.storage.StorageException- upon failure
-
forBucket
Returns Google Cloud StorageFileSystemobject forbucket.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.
-
forBucket
@CheckReturnValue public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config) Creates new file system instance forbucket, with customizable settings.- See Also:
-
forBucket
@CheckReturnValue public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config, @Nullable com.google.cloud.storage.StorageOptions storageOptions) Returns Google Cloud StorageFileSystemobject forbucket.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 inCloudStorageFileSystemProvider.newFileSystem(URI, java.util.Map)- See Also:
-
provider
- Specified by:
providerin classFileSystem
-
bucket
Returns Cloud Storage bucket name being served by this file system. -
config
Returns configuration object for this file system instance. -
getPath
Converts Cloud Storage object name to aPathobject.- Specified by:
getPathin classFileSystem
-
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.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classFileSystem- Throws:
IOException
-
isOpen
public boolean isOpen()Returnstrue, even if you previously called theclose()method.- Specified by:
isOpenin classFileSystem
-
isReadOnly
public boolean isReadOnly()Returnsfalse.- Specified by:
isReadOnlyin classFileSystem
-
getSeparator
Returns '/'.- Specified by:
getSeparatorin classFileSystem
-
getRootDirectories
- Specified by:
getRootDirectoriesin classFileSystem
-
getFileStores
Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or anything similar.- Specified by:
getFileStoresin classFileSystem
-
supportedFileAttributeViews
- Specified by:
supportedFileAttributeViewsin classFileSystem
-
getPathMatcher
- Specified by:
getPathMatcherin classFileSystem
-
getUserPrincipalLookupService
ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet.- Specified by:
getUserPrincipalLookupServicein classFileSystem
-
newWatchService
ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet.- Specified by:
newWatchServicein classFileSystem- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-