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.void
close()
Does nothing currently.config()
Returns configuration object for this file system instance.boolean
static CloudStorageFileSystem
Returns Google Cloud StorageFileSystem
object forbucket
.static CloudStorageFileSystem
forBucket
(String bucket, CloudStorageConfiguration config) Creates new file system instance forbucket
, with customizable settings.static CloudStorageFileSystem
forBucket
(String bucket, CloudStorageConfiguration config, com.google.cloud.storage.StorageOptions storageOptions) Returns Google Cloud StorageFileSystem
object forbucket
.Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or anything similar.Converts Cloud Storage object name to aPath
object.getPathMatcher
(String syntaxAndPattern) Returns '/'.ThrowsUnsupportedOperationException
because this feature hasn't been implemented yet.int
hashCode()
boolean
isOpen()
Returnstrue
, even if you previously called theclose()
method.boolean
Returnsfalse
.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.ThrowsUnsupportedOperationException
because 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 StorageFileSystem
object 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 StorageFileSystem
object 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:
provider
in 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 aPath
object.- Specified by:
getPath
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classFileSystem
- Throws:
IOException
-
isOpen
public boolean isOpen()Returnstrue
, even if you previously called theclose()
method.- Specified by:
isOpen
in classFileSystem
-
isReadOnly
public boolean isReadOnly()Returnsfalse
.- Specified by:
isReadOnly
in classFileSystem
-
getSeparator
Returns '/'.- Specified by:
getSeparator
in classFileSystem
-
getRootDirectories
- Specified by:
getRootDirectories
in classFileSystem
-
getFileStores
Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or anything similar.- Specified by:
getFileStores
in classFileSystem
-
supportedFileAttributeViews
- Specified by:
supportedFileAttributeViews
in classFileSystem
-
getPathMatcher
- Specified by:
getPathMatcher
in classFileSystem
-
getUserPrincipalLookupService
ThrowsUnsupportedOperationException
because this feature hasn't been implemented yet.- Specified by:
getUserPrincipalLookupService
in classFileSystem
-
newWatchService
ThrowsUnsupportedOperationException
because this feature hasn't been implemented yet.- Specified by:
newWatchService
in classFileSystem
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-