GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Add from and to storage url options for BlobId by JesseLovelace · Pull Request #888 · googleapis/java-storage

This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Conversation

@JesseLovelace

@JesseLovelace JesseLovelace commented Jun 18, 2021

Copy link
Copy Markdown
Contributor

Adds options for creating a blob ID from a storage url and vice versa. Fixes #868

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JesseLovelace
Add from and to storage url options for BlobId
f34ee55
@JesseLovelace
JesseLovelace requested review from a team and BenWhitehead June 18, 2021 00:37
@product-auto-label product-auto-label Bot added the api: storage Issues related to the googleapis/java-storage API. label Jun 18, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 18, 2021
@JesseLovelace JesseLovelace changed the title Add from and to storage url options for BlobId feat: Add from and to storage url options for BlobId Jun 18, 2021
BenWhitehead
BenWhitehead approved these changes Jun 21, 2021
View reviewed changes
Comment thread google-cloud-storage/src/main/java/com/google/cloud/storage/BlobId.java Outdated
*
* @param storageUrl the Storage url to create the blob from
*/
public static BlobId fromStorageUrl(String storageUrl) {

@BenWhitehead BenWhitehead Jun 21, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe fromGsutilUri instead of storage? To my knowledge, there are many different types of storage URLs

  • https://storage.googleapis.com/bucket/blob
  • https://storage.cloud.google.com/bucket/blob

In the cloud console these format of URI are labeled gsutil URI
image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-storage/src/main/java/com/google/cloud/storage/BlobId.java Outdated
Comment on lines +132 to +133
String bucketName = storageUrl.split("/")[2];
String blobName = storageUrl.split(bucketName + "/")[1];

@BenWhitehead BenWhitehead Jun 21, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly simplify string allocation and traversal?

Suggested change
String bucketName = storageUrl.split("/")[2];
String blobName = storageUrl.split(bucketName + "/")[1];
int blobNameStartIndex = storageUrl.indexOf('/', 5);
String bucketName = storageUrl.substring(5, blobNameStartIndex);
String blobName = storageUrl.substring(blobNameStartIndex);

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JesseLovelace
Better name
3a9d398
@JesseLovelace
JesseLovelace merged commit 1876a58 into master Jun 24, 2021
@JesseLovelace
JesseLovelace deleted the blobtofromurl branch June 24, 2021 22:07
gcf-merge-on-green Bot pushed a commit that referenced this pull request Jun 28, 2021
@release-please
chore: release 1.117.0 (#880)
aadd049
🤖 I have created a release \*beep\* \*boop\*
---
## [1.117.0](https://www.github.com/googleapis/java-storage/compare/v1.116.0...v1.117.0) (2021-06-28)


### Features

* Add from and to storage url options for BlobId ([#888](https://www.github.com/googleapis/java-storage/issues/888)) ([1876a58](https://www.github.com/googleapis/java-storage/commit/1876a580f904d095ca6621c1e2f38c3a6e253276))
* add support of public access prevention ([#636](https://www.github.com/googleapis/java-storage/issues/636)) ([3d1e482](https://www.github.com/googleapis/java-storage/commit/3d1e48208c44c35c8e3761913bcd05c438e81069))


### Bug Fixes

* Add `shopt -s nullglob` to dependencies script ([#894](https://www.github.com/googleapis/java-storage/issues/894)) ([901fd33](https://www.github.com/googleapis/java-storage/commit/901fd335c8d2f2e49844dee2adfa318a98ed99ba))
* Update dependencies.sh to not break on mac ([#879](https://www.github.com/googleapis/java-storage/issues/879)) ([bc6d1d9](https://www.github.com/googleapis/java-storage/commit/bc6d1d9e211fbbb1accd1019c8eed4bc55ca421c))


### Documentation

* add notice about broken OLM experience ([#898](https://www.github.com/googleapis/java-storage/issues/898)) ([73e7cdf](https://www.github.com/googleapis/java-storage/commit/73e7cdf162be76a8438160f4c7f2070fb6fb5ea6))


### Dependencies

* update dependency com.google.apis:google-api-services-storage to v1-rev20210127-1.31.5 ([#889](https://www.github.com/googleapis/java-storage/issues/889)) ([99138a4](https://www.github.com/googleapis/java-storage/commit/99138a4cd3523cc634e3c5283a775a1c245b6201))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
@release-please release-please Bot mentioned this pull request Aug 10, 2022
chore(main): release 2.11.4 #1564
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@BenWhitehead BenWhitehead BenWhitehead approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the googleapis/java-storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add fromStorageUrl and toStorageUrl methods to BlobId

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@JesseLovelace @BenWhitehead
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.