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

Get blob metadata implementation #152

Merged
merged 5 commits into from
Jan 20, 2021
Merged

Conversation

MindFlavor
Copy link
Contributor

Fixes #115

This PR:

Done:

  • Implements the function get_metatadata() in the blob client. The function does not require parameters and returns a GetBlobMetadataResponse with the response headers along with the parsed metadata.
  • Changes the value type of the Metadata struct to bytes::Bytes (previously it was String). This is done to better align with HeaderValue. HeaderValue does not force its contains to be a valid str so we do not require it either.

ToDo:

  • Support for encryption (as a whole, the SDK does not yet support version 2019-02-02 features).

Out of scope

Metadata poses limitations on the "key" name (it must adhere to the naming rules for C# identifiers). The SDK does not enforce it. It relies on server sides errors instead.

Copy link
Contributor

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Looks good. Just some small nits.

}

pub fn get(&self, k: &str) -> Option<Bytes> {
self.0.get(k).map(|b| b.clone())
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to eagerly clone instead of returning a &Bytes and letting the user decide? I guess cloning Bytes is fairly inexpensive....

headers
.iter()
.filter(|header| header.0.as_str().starts_with("x-ms-meta-"))
.for_each(|header| {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you deconstruct the header binding as (key, value)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

Copy link
Contributor Author

@MindFlavor MindFlavor Jan 20, 2021

Choose a reason for hiding this comment

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

Also it's probably best to move this code to the Metadata struct.

@MindFlavor MindFlavor merged commit bee9003 into master Jan 20, 2021
@MindFlavor MindFlavor deleted the impl/storage/get-blob-metadata branch January 20, 2021 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get-blob-metadata missing
2 participants