-
Notifications
You must be signed in to change notification settings - Fork 12
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
Enable inline view of assets #1534
Conversation
@waxlamp - it would be nice if we could view any text/png/jpeg files as well. if i click on the eye right now for a |
Hm. Did you try this through the staging deploy preview? When I tried with a .txt file locally, it worked as expected. If you try to open a text file in your browser directly, does it display it or offer to download it? |
Note that the deploy previews don't include server changes. So if that's what's being used for testing, that would explain the inconsistencies. |
Thanks @mvandenburgh, this would explain why it's not working--the query parameter specifying the content disposition would simply be ignored, resulting in the same behavior for 👁️ as ⬇️. |
Specifically: - `controls` shows the playback controls - `autoplay` begins the video playing as soon as possible - `muted` means the video won't blare audio when it begins autoplaying (this is actually required to make autoplay work on certain browsers, but it's a nice thing to do for the user anyway)
So, in addition to not working via the deploy preview, @mvandenburgh also helped me figure out a different problem: this feature worked when using the It will still not work via deploy previews. To test locally, check out this branch and build the software, then create a new Dandiset. Run Now you can visit your dandiset in the browser and experiment with how it behaves under the download and "eye" icons. UPDATE (2023-03-15 10:24): I forgot to mention that there are two text files in that bundle, |
dandiapi/api/views/common.py
Outdated
CONTENT_DISPOSITION_PARAM = openapi.Parameter( | ||
'content_disposition', | ||
openapi.IN_QUERY, | ||
'Content Disposition', | ||
type=openapi.TYPE_STRING, | ||
required=False, | ||
pattern='inline|attachment', | ||
) | ||
|
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.
This can be removed if the suggestion about manual_parameters
is applied
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.
See 5eba818.
dandiapi/api/views/serializers.py
Outdated
content_disposition = serializers.CharField(default='attachment') | ||
|
||
def validate_content_disposition(self, value): | ||
if value not in ['attachment', 'inline']: | ||
raise ValidationError( | ||
f'Illegal value {value} for parameter "content_disposition"', code=400 | ||
) | ||
return value |
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.
I overlooked this in my previous review comment - instead of using a CharField
with a validator, we can just use a ChoiceField
here.
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.
Good catch -- see bb5f924.
Closes #1389
Closes #1057
This is a simple premise: add the generation of asset download URLs with a content-disposition of
inline
, and use those to drive an in-browser view of assets in the file browser.This works for many file types, including text files and video files, but specifically not for
.mkv
files. This PR contains a hack to generate an HTML response with a<video>
tag that "shims" the lack of support for those files.