Skip to content

Does there exist a function to parse gs url into a bucket part and a blob part? #2363

@derekhh

Description

@derekhh

If I understand correctly, the way to fetch blob content from Google Cloud Storage, as suggested by the google-cloud-java API, right now is using something like:

Storage storage = StorageOptions.getDefaultInstance().getService();
BlobId blobId = BlobId.of("bucket", "blob_name");
Blob blob = storage.get(blobId);
byte[] content = blob.getContent();

This requires us to pass in two arguments: bucket and blob_name, but normally what we would want to pass in, originally, would be a gs:// url.

I want to know whether there exists a function that can parse a gs URL and return the bucket and blob parts, like the parseGlob function here. I feel this might be something that exists in the google-cloud-java library already so I don't need to reinvent the wheel.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions