file api
This commit is contained in:
@@ -31,8 +31,19 @@ export class Attachment extends PureComponent {
|
||||
if (onClick && attachment) {
|
||||
onClick(attachment);
|
||||
} else if (attachment?.file instanceof Blob || attachment?.file instanceof File) {
|
||||
const url = URL.createObjectURL(attachment.file);
|
||||
window.open(url, '_blank');
|
||||
if (attachment.file.size > 0) {
|
||||
const url = URL.createObjectURL(attachment.file);
|
||||
window.open(url, '_blank');
|
||||
} else {
|
||||
const docId = attachment.manifestId;
|
||||
const fileId = attachment.fileId ?? attachment.id;
|
||||
if (docId != null && fileId != null) {
|
||||
window.open(
|
||||
`/api/delivery/${encodeURIComponent(docId)}/file/${encodeURIComponent(fileId)}`,
|
||||
'_blank',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,7 +60,8 @@ export class Attachment extends PureComponent {
|
||||
const name = attachment?.name || 'Dokument';
|
||||
const size = attachment?.size;
|
||||
const isPdf = attachment?.type === 'application/pdf' || name.toLowerCase().endsWith('.pdf');
|
||||
const isText = attachment?.type?.startsWith('text/') || name.toLowerCase().endsWith('.txt');
|
||||
const isCsv = attachment?.type === 'text/csv' || name.toLowerCase().endsWith('.csv');
|
||||
const isText = attachment?.type?.startsWith('text/') || name.toLowerCase().endsWith('.txt') || isCsv;
|
||||
|
||||
return (
|
||||
<Box
|
||||
@@ -125,7 +137,7 @@ export class Attachment extends PureComponent {
|
||||
letterSpacing: '0.05em',
|
||||
}}
|
||||
>
|
||||
TXT
|
||||
{isCsv ? 'CSV' : 'TXT'}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Typography
|
||||
|
||||
Reference in New Issue
Block a user