Allow frontend to use mime_type property

This commit is contained in:
shamoon
2024-10-15 11:27:39 -07:00
parent 346b0fab8e
commit 5ffc39feff
6 changed files with 37 additions and 38 deletions

View File

@@ -46,8 +46,8 @@ export class PreviewPopupComponent implements OnDestroy {
get isPdf(): boolean {
// We dont have time to retrieve metadata, make a best guess by file name
return (
this.document?.original_file_name?.endsWith('.pdf') ||
this.document?.archived_file_name?.endsWith('.pdf')
this.document?.archived_file_name?.length > 0 ||
this.document?.mime_type?.includes('pdf')
)
}
@@ -62,17 +62,19 @@ export class PreviewPopupComponent implements OnDestroy {
}
init() {
this.http
.get(this.previewURL, { responseType: 'text' })
.pipe(first(), takeUntil(this.unsubscribeNotifier))
.subscribe({
next: (res) => {
this.previewText = res.toString()
},
error: (err) => {
this.error = err
},
})
if (this.document.mime_type?.includes('text')) {
this.http
.get(this.previewURL, { responseType: 'text' })
.pipe(first(), takeUntil(this.unsubscribeNotifier))
.subscribe({
next: (res) => {
this.previewText = res.toString()
},
error: (err) => {
this.error = err
},
})
}
}
onError(event: any) {