mirror of https://github.com/nocodb/nocodb
Browse Source
* feat: allow preview for media types * feat: attachment download endpoint * fix: render attachment modal only on expand * feat: attachment download front-end * fix: add download attachment endpoint to secure controller * fix: use api instead of direct access * fix: bulk download attachments * feat: public attachment download api * fix: add swagger to support shared base * fix: apply latest signed url change Signed-off-by: mertmit <mertmit99@gmail.com> --------- Signed-off-by: mertmit <mertmit99@gmail.com>pull/9066/head
Mert E.
4 months ago
committed by
GitHub
17 changed files with 586 additions and 67 deletions
@ -0,0 +1,23 @@
|
||||
import mime from 'mime/lite'; |
||||
|
||||
const previewableMimeTypes = ['image', 'pdf', 'video', 'audio']; |
||||
|
||||
export function isPreviewAllowed(args: { mimetype?: string; path?: string }) { |
||||
const { mimetype, path } = args; |
||||
|
||||
if (mimetype) { |
||||
return previewableMimeTypes.some((type) => mimetype.includes(type)); |
||||
} else if (path) { |
||||
const ext = path.split('.').pop(); |
||||
|
||||
// clear query params
|
||||
const extWithoutQuery = ext?.split('?')[0]; |
||||
|
||||
if (extWithoutQuery) { |
||||
const mimeType = mime.getType(extWithoutQuery); |
||||
return previewableMimeTypes.some((type) => mimeType?.includes(type)); |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
Loading…
Reference in new issue