Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add from and to storage url options for BlobId #888

Merged
merged 2 commits into from
Jun 24, 2021

Conversation

JesseLovelace
Copy link
Contributor

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

@JesseLovelace JesseLovelace requested review from BenWhitehead and a team 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
*
* @param storageUrl the Storage url to create the blob from
*/
public static BlobId fromStorageUrl(String storageUrl) {
Copy link
Collaborator

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

Comment on lines 132 to 133
String bucketName = storageUrl.split("/")[2];
String blobName = storageUrl.split(bucketName + "/")[1];
Copy link
Collaborator

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);

@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
🤖 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add fromStorageUrl and toStorageUrl methods to BlobId
2 participants