diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index 33998f81a..6c1bb7c9c 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.py @@ -135,7 +135,7 @@ "Use Blob.download_as_bytes() instead." ) _GS_URL_REGEX_PATTERN = re.compile( - r"(?Pgs)://(?P[a-z0-9_.-]+)/(?P.+)" + r"(?Pgs)://(?P[a-z0-9_.-]+)(?P:/)?(?P.+)" ) _DEFAULT_CHUNKSIZE = 104857600 # 1024 * 1024 B * 100 = 100 MB @@ -407,7 +407,7 @@ def from_string(cls, uri, client=None): match = _GS_URL_REGEX_PATTERN.match(uri) if not match: - raise ValueError("URI scheme must be gs") + raise ValueError(f"URI scheme should match regex '{_GS_URL_REGEX_PATTERN}'") bucket = Bucket(client, name=match.group("bucket_name")) return cls(match.group("object_name"), bucket)