Specify blob media type on creation#366
Open
rwb27 wants to merge 3 commits into
Open
Conversation
This allows a more specific media type to be specified when creating a `Blob` instance. This would allow `Blob.from_bytes` to set any media type, or would allow a `Blob` subclass where the first part of the media type is specified (e.g. `image/*`) to have any media type starting with `image/`. This is tested in `test_blob_output.py`
Barecheck - Code coverage reportTotal: 96.98%Your code coverage diff: 0.01% ▴ Uncovered files and lines
|
| """ | ||
|
|
||
|
|
||
| class MediaTypeMismatchError(ValueError): |
Contributor
There was a problem hiding this comment.
Would be good to clarify this that you mean the specified media string. I read MediaTypeMismatchError and the docstring as the actual media type of the file itself not matching the specifiecation
Collaborator
Author
There was a problem hiding this comment.
I've rewritten the docstring accordingly. I feel like this exception is probably appropriate for either case, but currently we only check the supplied media type: the binary data or file doesn't specify a media type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
media_typeargument to the four class methods that are used to createBlobinstances. That allows the media type to be set (and checked against the class media type).I think the checking is worthwhile for when we have something like an
ImageBlobwhich would havemedia_type="image/*", and so you can then create an instance with any legal media type starting withimage/.The validation logic was already present in
Bloband is tested.Closes #357
Closes #352