Skip to content

Storage: Client.download_blob_to_file fails. #8301

@pepnova-9

Description

@pepnova-9

Client.download_blob_to_file() does not work properly when passing a URI because the parsed path which is passed as a blob name has the initial / .

https://github.com/googleapis/google-cloud-python/blob/master/storage/google/cloud/storage/client.py#L389-L395

It should be removed from the path before passing into a Blob constructor.

            scheme, netloc, path, query, frag = urlsplit(blob_or_uri)
            if scheme != "gs":
                raise ValueError("URI scheme must be gs")
            blob_name = path[1:]
            bucket = Bucket(self, name=netloc)
            blob_or_uri = Blob(blob_name, bucket)

            blob_or_uri.download_to_file(file_obj, client=self, start=start, end=end)

BTW: I tried to create a pull request to fix it but I was not allowed to push my commit into this repo. How can I contribute?

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