Use inline content disposition for common images and PDFs (#6924)

* Use inline content disposition for common images and PDFs

* Add double-click on widgets to download
This commit is contained in:
Tom Moor
2024-05-18 12:17:04 -04:00
committed by GitHub
parent c872f3e245
commit cd4f3f9ff2
5 changed files with 51 additions and 7 deletions

View File

@@ -214,4 +214,29 @@ export default abstract class BaseStorage {
* @returns A promise that resolves when the file is deleted
*/
public abstract deleteFile(key: string): Promise<void>;
/**
* Returns the content disposition for a given content type.
*
* @param contentType The content type
* @returns The content disposition
*/
public getContentDisposition(contentType?: string) {
if (contentType && this.safeInlineContentTypes.includes(contentType)) {
return "inline";
}
return "attachment";
}
/**
* A list of content types considered safe to display inline in the browser.
*/
protected safeInlineContentTypes = [
"application/pdf",
"image/png",
"image/jpeg",
"image/gif",
"image/webp",
];
}