Skip to content

[GCP-5538] Storage: Missing support for HTTP Headers and Query String Parameters - #17

Draft
HemangChothani wants to merge 3 commits into
masterfrom
feature/support_http_headers
Draft

[GCP-5538] Storage: Missing support for HTTP Headers and Query String Parameters#17
HemangChothani wants to merge 3 commits into
masterfrom
feature/support_http_headers

Conversation

@HemangChothani

@HemangChothaniHemangChothani commented Jul 31, 2019

Copy link
Copy Markdown
Collaborator

Addressing #5538

@HemangChothaniHemangChothani changed the title Storage: Fix/add support for http headers and query parameters/5538Storage: Add support for http headers and query parameters/5538Jul 31, 2019
@mf2199mf2199 changed the title Storage: Add support for http headers and query parameters/5538[GCP-5538] Storage: Missing support for HTTP Headers and Query String ParametersJul 31, 2019
Comment threadstorage/google/cloud/storage/client.py
blob_or_uri.download_to_file(file_obj, client=self, start=start, end=end)
blob_or_uri.download_to_file(
file_obj, client=self, start=start, end=end, query_params=query_params
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This repeats lines 402-404. Is there any way to check the type and validate the blob_or_uri parameter before the try...except clause and avoid an unnecessary API call?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I have only added query_params parameter not added try..except and is it fine to change their usecase?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It should be fine as long as two API calls were there initially, I just thought we could improve on that too, along the way.

Comment threadstorage/google/cloud/storage/client.py
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/tests/unit/test_blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/google/cloud/storage/blob.py Outdated
client=client,
start=start,
end=end,
query_params=query_params,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove the extra "comma" after query params.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

if i remove "comma" than blacken test failed, you can see also in client.py that added "comma" after client parameter

client=client,
start=start,
end=end,
query_params=query_params,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove extra comma.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Same as above

size,
num_retries,
predefined_acl,
extra_headers,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove "comma" after extra_headers.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

same as above

Comment threadstorage/google/cloud/storage/blob.py Outdated
Comment threadstorage/tests/unit/test_blob.py

@emar-karemar-kar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM
Nevertheless I'm really advising to follow @mf2199 advises about custom spelling.

@HemangChothani

Copy link
Copy Markdown
CollaboratorAuthor

Yes , i did that, but i followed docs url where i found Extension (Custom) HTTP Headers so i used same as documented.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It should be fine as long as two API calls were there initially, I just thought we could improve on that too, along the way.

Comment threadstorage/google/cloud/storage/client.py
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@HemangChothani@mf2199@sumit-ql@emar-kar