Class CloudStorageFileSystemProvider (0.127.38) 
  
  
  
   
  
    
  
  
    
    
    
    
  Version 0.127.38keyboard_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.
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  
      
        newStorageOptionscom.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  
      
        pathPath  
      
        typeClass <A > 
      
        optionsjava.nio.file.LinkOption [] 
     
  
  
    
      
        Returns  
      
        Type Description  
      
        A  
     
  
  Overrides 
  
  
  <V>getFileAttributeView(Path path, Class<V> type, LinkOption[] options) 
  
    
public   V   <V>getFileAttributeView ( Path   path ,   Class<V>   type ,   LinkOption []   options )  
  
    
      
        Parameters  
      
        Name Description  
      
        pathPath  
      
        typeClass <V > 
      
        optionsjava.nio.file.LinkOption [] 
     
  
  
    
      
        Returns  
      
        Type Description  
      
        V  
     
  
  Overrides 
  
  checkAccess(Path path, AccessMode[] modes) 
  
    
public   void   checkAccess ( Path   path ,   AccessMode []   modes )  
  
    
      
        Parameters  
      
        Name Description  
      
        pathPath  
      
        modesjava.nio.file.AccessMode [] 
     
  
  Overrides 
  
  
  copy(Path source, Path target, CopyOption[] options) 
  
    
public   void   copy ( Path   source ,   Path   target ,   CopyOption []   options )  
  
  Overrides 
  
  
  createDirectory(Path dir, FileAttribute<?>[] attrs) 
  
    
public   void   createDirectory ( Path   dir ,   FileAttribute <?>[]   attrs )  
  Does nothing since Google Cloud Storage uses fake directories.
Overrides 
  
  delete(Path path) 
  
    
public   void   delete ( Path   path )  
  
    
      
        Parameter  
      
        Name Description  
      
        pathPath  
     
  
  Overrides 
  
  
  deleteIfExists(Path path) 
  
    
public   boolean   deleteIfExists ( Path   path )  
  
    
      
        Parameter  
      
        Name Description  
      
        pathPath  
     
  
  
  Overrides 
  
  
  equals(Object other) 
  
    
public   boolean   equals ( Object   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherObject  
     
  
  
  Overrides 
  
  getFileStore(Path path) 
  
    
public   FileStore   getFileStore ( Path   path )  
  
  
    
      
        Parameter  
      
        Name Description  
      
        pathPath  
     
  
  
  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  
      
        Name Description  
      
        uriURI  
     
  
  
  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  
      
        uriInStringFormString  
     
  
  
  getPath(URI uri) 
  
    
public   CloudStoragePath   getPath ( URI   uri )  
  
    
      
        Parameter  
      
        Name Description  
      
        uriURI  
     
  
  
  Overrides 
  
  getProject() 
  
    
public   String   getProject ()  
  Returns the project that is assigned to this provider.
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  getScheme() 
  
    
public   String   getScheme ()  
  
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  Overrides 
  
  hashCode() 
  
  
    
      
        Returns  
      
        Type Description  
      
        int  
     
  
  Overrides 
  
  isHidden(Path path) 
  
    
public   boolean   isHidden ( Path   path )  
  Always returns false, because Google Cloud Storage doesn't support hidden files.
    
      
        Parameter  
      
        Name Description  
      
        pathPath  
     
  
  
  Overrides 
  
  isSameFile(Path path, Path path2) 
  
    
public   boolean   isSameFile ( Path   path ,   Path   path2 )  
  
    
      
        Parameters  
      
        Name Description  
      
        pathPath  
      
        path2Path  
     
  
  
  Overrides 
  
  move(Path source, Path target, CopyOption[] options) 
  
    
public   void   move ( Path   source ,   Path   target ,   CopyOption []   options )  
  
  Overrides 
  
  
  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  
      
        pathPath : the path to the file to open or create
 
      
        optionsSet <? extends java.nio.file.OpenOption >: options specifying how the file is opened, e.g. StandardOpenOption.WRITE or
     BlobSourceOption.userProject
 
      
        attrsFileAttribute <? >[]: (not supported, values will be ignored)
 
     
  
  
  Overrides 
  
  
  newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) 
  
    
public   DirectoryStream<Path>   newDirectoryStream ( Path   dir ,   DirectoryStream . Filter <?   super   Path >  filter )  
  
    
      
        Parameters  
      
        Name Description  
      
        dirPath  
      
        filterFilter <? super java.nio.file.Path > 
     
  
  
  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  
      
        pathPath The path to the file to open or create
 
      
        optionsSet <? 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.
 
      
        attrsFileAttribute <? >[](not supported, the values will be ignored)
 
     
  
  
  Overrides 
  
  
  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  
      
        uriURI bucket and current working directory, e.g. gs://bucket
 
      
        envMap <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
 
     
  
  
  Overrides 
  
  
    
public   InputStream   newInputStream ( Path   path ,   OpenOption []   options )  
  
  
  Overrides 
  
  
  readAttributes(Path path, String attributes, LinkOption[] options) 
  
    
public   Map<String , Object >  readAttributes ( Path   path ,   String   attributes ,   LinkOption []   options )  
  
    
      
        Parameters  
      
        Name Description  
      
        pathPath  
      
        attributesString  
      
        optionsjava.nio.file.LinkOption [] 
     
  
  
  Overrides 
  
  
  requesterPays(String bucketName) 
  
    
public   boolean   requesterPays ( String   bucketName )  
  
    
      
        Parameter  
      
        Name Description  
      
        bucketNameString 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  
      
        pathPath  
      
        attributeString  
      
        valueObject  
      
        optionsjava.nio.file.LinkOption [] 
     
  
  Overrides 
  
  toString() 
  
  
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  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.
 
     
    
  
  
  
     
  
    
    
      
       
    
    
  
  
 
  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 2025-10-29 UTC.
 
 
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-29 UTC."],[],[]]