Package com.google.cloud.spring.storage
Class GoogleStorageLocation
java.lang.Object
com.google.cloud.spring.storage.GoogleStorageLocation
Represents a Google Cloud Storage location provided by the user.
- Since:
- 1.2
-
Constructor Summary
ConstructorsConstructorDescriptionGoogleStorageLocation(String gcsLocationUriString) Constructs aGoogleStorageLocationbased on the provided Google Storage URI string. -
Method Summary
Modifier and TypeMethodDescriptionstatic GoogleStorageLocationReturns aGoogleStorageLocationto a bucket.static GoogleStorageLocationReturns aGoogleStorageLocationfor a file within a bucket.static GoogleStorageLocationReturns aGoogleStorageLocationto a folder whose path is relative to the bucket.Returns the path to the blob/folder relative from the bucket root.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.toString()uri()Returns the GCS URI of the location.Returns the Google Storage URI string for the location.
-
Constructor Details
-
GoogleStorageLocation
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 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 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
Returns the Google Storage bucket name.- Returns:
- the name of the Google Storage bucket
-
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
Returns the GCS URI of the location.- Returns:
- the URI object of the Google Storage location.
-
uriString
Returns the Google Storage URI string for the location.- Returns:
- the URI string of the Google Storage location.
-
forBucket
Returns aGoogleStorageLocationto a bucket.- Parameters:
bucketName- name of the GCS bucket- Returns:
- the
GoogleStorageLocationto the location.
-
forFile
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
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.
-
toString
-