feat(#1839): Add Audio and Video Preview (#1840)

Any audio and video response can be now be previewed.
This commit is contained in:
Bobby 2024-03-22 20:59:39 +08:00 committed by GitHub
parent 82c600a0e6
commit 7741a3e4ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View File

@ -65,6 +65,16 @@ const QueryResultPreview = ({
</div>
);
}
case 'preview-audio': {
return (
<audio controls src={`data:${contentType.replace(/\;(.*)/, '')};base64,${dataBuffer}`} className="mx-auto" />
);
}
case 'preview-video': {
return (
<video controls src={`data:${contentType.replace(/\;(.*)/, '')};base64,${dataBuffer}`} className="mx-auto" />
);
}
default:
case 'raw': {
return (

View File

@ -67,6 +67,10 @@ const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEven
allowedPreviewModes.unshift('preview-image');
} else if (contentType.includes('pdf')) {
allowedPreviewModes.unshift('preview-pdf');
} else if (contentType.includes('audio')) {
allowedPreviewModes.unshift('preview-audio');
} else if (contentType.includes('video')) {
allowedPreviewModes.unshift('preview-video');
}
return allowedPreviewModes;

View File

@ -25,6 +25,7 @@ const contentSecurityPolicy = [
// this has been commented out to make oauth2 work
// "form-action 'none'",
"img-src 'self' blob: data: https:",
"media-src 'self' blob: data: https:",
"style-src 'self' 'unsafe-inline' https:"
];