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
ConstructorDescriptionGoogleStorageLocation
(String gcsLocationUriString) Constructs aGoogleStorageLocation
based on the provided Google Storage URI string. -
Method Summary
Modifier and TypeMethodDescriptionstatic GoogleStorageLocation
Returns aGoogleStorageLocation
to a bucket.static GoogleStorageLocation
Returns aGoogleStorageLocation
for a file within a bucket.static GoogleStorageLocation
Returns aGoogleStorageLocation
to 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.boolean
isBucket()
Check if the location references a bucket and not a blob.boolean
isFile()
Returns whether thisGoogleStorageLocation
represents a file or not.boolean
isFolder()
Returns whether thisGoogleStorageLocation
represents a folder.toString()
uri()
Returns the GCS URI of the location.Returns the Google Storage URI string for the location.
-
Constructor Details
-
GoogleStorageLocation
Constructs aGoogleStorageLocation
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 thisGoogleStorageLocation
represents a file or not.- Returns:
- true if the location describes a file
-
isFolder
public boolean isFolder()Returns whether thisGoogleStorageLocation
represents 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 theGoogleStorageLocation
specifies 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 aGoogleStorageLocation
to a bucket.- Parameters:
bucketName
- name of the GCS bucket- Returns:
- the
GoogleStorageLocation
to the location.
-
forFile
Returns aGoogleStorageLocation
for a file within a bucket.- Parameters:
bucketName
- name of the GCS bucketpathToFile
- path to the file within the bucket- Returns:
- the
GoogleStorageLocation
to the location.
-
forFolder
Returns aGoogleStorageLocation
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
-