Send feedback
Class CloudStorageFileSystemProvider (0.123.28)
Stay organized with collections
Save and categorize content based on your preferences.
Version 0.123.28 keyboard_arrow_down
public final class CloudStorageFileSystemProvider extends FileSystemProvider
Google Cloud Storage FileSystemProvider implementation.
Note: This class should never be used directly. This class is instantiated by the
service loader and called through a standardized API, e.g. java.nio.file.Files . However
the javadocs in this class serve as useful documentation for the behavior of the Google Cloud
Storage NIO library.
Static Methods
setDefaultCloudStorageConfiguration(CloudStorageConfiguration newDefault)
public static void setDefaultCloudStorageConfiguration ( CloudStorageConfiguration newDefault )
Changes the default configuration for every filesystem object created from here on, including
via SPI. If null then future filesystem objects will have the factory default configuration.
If options are specified later then they override the defaults. Methods that take a whole
CloudStorageConfiguration (eg. CloudStorageFileSystem.forBucket) will completely override the
defaults. Methods that take individual options (eg.
CloudStorageFileSystemProvier.newFileSystem) will override only these options; the rest will be
taken from the defaults specified here.
This is meant to be done only once, at the beginning of some main program, in order to force
all libraries to use some settings we like.
Libraries should never call this. If you're a library then, instead, create your own
filesystem object with the right configuration and pass it along.
Parameter
setStorageOptions(StorageOptions newStorageOptions)
public static void setStorageOptions ( StorageOptions newStorageOptions )
Sets options that are only used by the constructor.
Instead of calling this, when possible use CloudStorageFileSystem.forBucket and pass
StorageOptions as an argument.
Parameter
Name Description newStorageOptions com.google.cloud.storage.StorageOptions
Constructors
CloudStorageFileSystemProvider()
public CloudStorageFileSystemProvider ()
Methods
<A>readAttributes(Path path, Class<A> type, LinkOption[] options)
public A <A>readAttributes ( Path path , Class<A> type , LinkOption [] options )
Parameters
Name Description path Path
type Class <A >
options java.nio.file.LinkOption []
Returns
Overrides
Exceptions
<V>getFileAttributeView(Path path, Class<V> type, LinkOption[] options)
public V <V>getFileAttributeView ( Path path , Class<V> type , LinkOption [] options )
Parameters
Name Description path Path
type Class <V >
options java.nio.file.LinkOption []
Returns
Overrides
checkAccess(Path path, AccessMode[] modes)
public void checkAccess ( Path path , AccessMode [] modes )
Parameters
Name Description path Path
modes java.nio.file.AccessMode []
Overrides
Exceptions
copy(Path source, Path target, CopyOption[] options)
public void copy ( Path source , Path target , CopyOption [] options )
Parameters
Overrides
Exceptions
createDirectory(Path dir, FileAttribute<?>[] attrs)
public void createDirectory ( Path dir , FileAttribute <?>[] attrs )
Does nothing since Google Cloud Storage uses fake directories.
Parameters
Overrides
delete(Path path)
public void delete ( Path path )
Parameter
Overrides
Exceptions
deleteIfExists(Path path)
public boolean deleteIfExists ( Path path )
Parameter
Returns
Overrides
Exceptions
equals(Object other)
public boolean equals ( Object other )
Parameter
Returns
Overrides
getFileStore(Path path)
public FileStore getFileStore ( Path path )
Parameter
Returns
Overrides
getFileSystem(URI uri)
public CloudStorageFileSystem getFileSystem ( URI uri )
Returns Cloud Storage file system, provided a URI with no path, e.g. gs://bucket
.
Parameter
Returns
Overrides
getPath(String uriInStringForm)
public CloudStoragePath getPath ( String uriInStringForm )
Convenience method: replaces spaces with "%20", builds a URI, and calls getPath(uri).
Parameter
Name Description uriInStringForm String
Returns
getPath(URI uri)
public CloudStoragePath getPath ( URI uri )
Parameter
Returns
Overrides
getProject()
public String getProject ()
Returns the project that is assigned to this provider.
Returns
getScheme()
public String getScheme ()
Returns
Overrides
hashCode()
Returns
Overrides
isHidden(Path path)
public boolean isHidden ( Path path )
Always returns false
, because Google Cloud Storage doesn't support hidden files.
Parameter
Returns
Overrides
isSameFile(Path path, Path path2)
public boolean isSameFile ( Path path , Path path2 )
Parameters
Returns
Overrides
move(Path source, Path target, CopyOption[] options)
public void move ( Path source , Path target , CopyOption [] options )
Parameters
Overrides
Exceptions
newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs)
public SeekableByteChannel newByteChannel ( Path path , Set <? extends OpenOption > options , FileAttribute <?>[] attrs )
Open a file for reading or writing. To read receiver-pays buckets, specify the
BlobSourceOption.userProject option.
Parameters
Name Description path Path
: the path to the file to open or create
options Set <? extends java.nio.file.OpenOption >
: options specifying how the file is opened, e.g. StandardOpenOption.WRITE or
BlobSourceOption.userProject
attrs FileAttribute <? >[]
: (not supported, values will be ignored)
Returns
Overrides
Exceptions
newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
public DirectoryStream<Path> newDirectoryStream ( Path dir , DirectoryStream . Filter <? super Path > filter )
Parameters
Name Description dir Path
filter Filter <? super java.nio.file.Path >
Returns
Overrides
newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs)
public FileChannel newFileChannel ( Path path , Set <? extends OpenOption > options , FileAttribute <?>[] attrs )
Open a file for reading OR writing. The FileChannel that is returned will only allow
reads or writes depending on the OpenOption s that are specified. If any of the
following have been specified, the FileChannel will be write-only: StandardOpenOption#CREATE
StandardOpenOption#CREATE
StandardOpenOption#CREATE_NEW
StandardOpenOption#WRITE
StandardOpenOption#TRUNCATE_EXISTING
In all other cases the FileChannel will be read-only.
Parameters
Name Description path Path
The path to the file to open or create
options Set <? extends java.nio.file.OpenOption >
The options specifying how the file should be opened, and whether the FileChannel should be read-only or write-only.
attrs FileAttribute <? >[]
(not supported, the values will be ignored)
Returns
Overrides
Exceptions
newFileSystem(URI uri, Map<String,?> env)
public CloudStorageFileSystem newFileSystem ( URI uri , Map<String , ?> env )
Returns Cloud Storage file system, provided a URI, e.g. gs://bucket
. The URI can
include a path component (that will be ignored).
Parameters
Name Description uri URI
bucket and current working directory, e.g. gs://bucket
env Map <String ,? >
map of configuration options, whose keys correspond to the method names of CloudStorageConfiguration.Builder . However you are not allowed to set the working
directory, as that should be provided in the uri
Returns
Overrides
public InputStream newInputStream ( Path path , OpenOption [] options )
Parameters
Returns
Overrides
Exceptions
readAttributes(Path path, String attributes, LinkOption[] options)
public Map<String , Object> readAttributes ( Path path , String attributes , LinkOption [] options )
Parameters
Name Description path Path
attributes String
options java.nio.file.LinkOption []
Returns
Overrides
requesterPays(String bucketName)
public boolean requesterPays ( String bucketName )
Parameter
Name Description bucketName String
the name of the bucket to check
Returns
Type Description boolean whether requester pays is enabled for that bucket
setAttribute(Path path, String attribute, Object value, LinkOption[] options)
public void setAttribute ( Path path , String attribute , Object value , LinkOption [] options )
Parameters
Name Description path Path
attribute String
value Object
options java.nio.file.LinkOption []
Overrides
toString()
Returns
Overrides
withNoUserProject()
public CloudStorageFileSystemProvider withNoUserProject ()
Returns a NEW CloudStorageFileSystemProvider identical to this one, but with userProject
removed.
Perhaps you want to call this is you realize you'll be working on a bucket that is not
requester-pays.
Returns
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-04 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-10-04 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-04 UTC."]]