Package com.google.cloud.spring.storage
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 Summary
Constructors Constructor Description GoogleStorageLocation(String gcsLocationUriString)Constructs aGoogleStorageLocationbased on the provided Google Storage URI string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GoogleStorageLocationforBucket(String bucketName)Returns aGoogleStorageLocationto a bucket.static GoogleStorageLocationforFile(String bucketName, String pathToFile)Returns aGoogleStorageLocationfor a file within a bucket.static GoogleStorageLocationforFolder(String bucketName, String pathToFolder)Returns aGoogleStorageLocationto a folder whose path is relative to the bucket.StringgetBlobName()Returns the path to the blob/folder relative from the bucket root.StringgetBucketName()Returns the Google Storage bucket name.booleanisBucket()Check if the location references a bucket and not a blob.booleanisFile()Returns whether thisGoogleStorageLocationrepresents a file or not.booleanisFolder()Returns whether thisGoogleStorageLocationrepresents a folder.StringtoString()URIuri()Returns the GCS URI of the location.StringuriString()Returns the Google Storage URI string for the location.
-
-
-
Constructor Detail
-
GoogleStorageLocation
public GoogleStorageLocation(String gcsLocationUriString)
Constructs aGoogleStorageLocationbased 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 Detail
-
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 thisGoogleStorageLocationrepresents a file or not.- Returns:
- true if the location describes a file
-
isFolder
public boolean isFolder()
Returns whether thisGoogleStorageLocationrepresents 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 theGoogleStorageLocationspecifies 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 aGoogleStorageLocationto a bucket.- Parameters:
bucketName- name of the GCS bucket- Returns:
- the
GoogleStorageLocationto the location.
-
forFile
public static GoogleStorageLocation forFile(String bucketName, String pathToFile)
Returns aGoogleStorageLocationfor a file within a bucket.- Parameters:
bucketName- name of the GCS bucketpathToFile- path to the file within the bucket- Returns:
- the
GoogleStorageLocationto the location.
-
forFolder
public static GoogleStorageLocation forFolder(String bucketName, String pathToFolder)
Returns aGoogleStorageLocationto 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
GoogleStorageLocationto the location.
-
-