Class GoogleStorageLocation

java.lang.Object
com.google.cloud.spring.storage.GoogleStorageLocation

public class GoogleStorageLocation extends Object
Represents a Google Cloud Storage location provided by the user.
Since:
1.2
  • Constructor Details

    • GoogleStorageLocation

      public GoogleStorageLocation(String gcsLocationUriString)
      Constructs a GoogleStorageLocation based on the provided Google Storage URI string. The URI string is of the form: gs://<BUCKET_NAME>/<PATH_TO_FILE>
      Parameters:
      gcsLocationUriString - a Google Storage URI string to a bucket/folder/file.
  • Method Details

    • isBucket

      public boolean isBucket()
      Check if the location references a bucket and not a blob.
      Returns:
      if the location describes a bucket
    • isFile

      public boolean isFile()
      Returns whether this GoogleStorageLocation represents a file or not.
      Returns:
      true if the location describes a file
    • isFolder

      public boolean isFolder()
      Returns whether this GoogleStorageLocation represents a folder.
      Returns:
      true if the location describes a folder
    • getBucketName

      public String getBucketName()
      Returns the Google Storage bucket name.
      Returns:
      the name of the Google Storage bucket
    • getBlobName

      public String getBlobName()
      Returns the path to the blob/folder relative from the bucket root. Returns null if the GoogleStorageLocation specifies a bucket itself.
      Returns:
      a path to the blob or folder; null if the location is to a bucket.
    • uri

      public URI uri()
      Returns the GCS URI of the location.
      Returns:
      the URI object of the Google Storage location.
    • uriString

      public String uriString()
      Returns the Google Storage URI string for the location.
      Returns:
      the URI string of the Google Storage location.
    • forBucket

      public static GoogleStorageLocation forBucket(String bucketName)
      Returns a GoogleStorageLocation to a bucket.
      Parameters:
      bucketName - name of the GCS bucket
      Returns:
      the GoogleStorageLocation to the location.
    • forFile

      public static GoogleStorageLocation forFile(String bucketName, String pathToFile)
      Returns a GoogleStorageLocation for a file within a bucket.
      Parameters:
      bucketName - name of the GCS bucket
      pathToFile - path to the file within the bucket
      Returns:
      the GoogleStorageLocation to the location.
    • forFolder

      public static GoogleStorageLocation forFolder(String bucketName, String pathToFolder)
      Returns a GoogleStorageLocation to a folder whose path is relative to the bucket.
      Parameters:
      bucketName - name of the GCS bucket.
      pathToFolder - path to the folder within the bucket.
      Returns:
      the GoogleStorageLocation to the location.
    • toString

      public String toString()
      Overrides:
      toString in class Object