-
Notifications
You must be signed in to change notification settings - Fork 32
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
Handle Content-Type and Content-Disposition headers #90
Merged
Conversation
This file contains 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
Added new `get_mime_type()` method to `StreamingStorage` so that different backends can implement it. For local storage we use the builitin `mimetypes` module to guess the mime type from the filename, for Azure we get it from the blob properties. In the basic streaming transfer handler we read the value of this method and add it to the `Content-type` header.
This is currently inferred from the filename using `mimetypes`
shevron
reviewed
Apr 30, 2021
Also return a default value of `application/octet-stream` on the`get_mime_type()` method
As we don't have the actual file name that the mimetype module can use
Sometimes when requesting a file from Giftless we don't want it to receive it as an attachment, eg when loading it in a browser JS widget or embedding it. This change adds support for a `x-disposition` extra which storage backends can use to set the appropiate headers when returning a download URL.
amercader
changed the title
Handle Content-Type header
Handle Content-Type and Content-Disposition headers
May 13, 2021
shevron
approved these changes
May 14, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
amercader
added a commit
to datopian/ckanext-blob-storage
that referenced
this pull request
May 14, 2021
Actually all these changes do is supporting an incoming `?preview=1` query argument on download URLs and forward the `x-disposition = inline` extra to Giftless when requesting the download URL. At that point datopian/giftless#90 will kick in and the storage backend will return the appropiate headers. The only way to pass this parameter all the way down to the action that requests the downloadURL was to add a new argument to the download handlers. This would break backwards compatibility so I've added code to support plugin hooks that don't support the new `inline` arg.
@amercader I've just issued a new tag / release, Docker image with version Thanks for the PR :) |
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 follows up discussion on #88