Can force file download
This commit is contained in:
@ -41,7 +41,10 @@ export class FileApi {
|
||||
/**
|
||||
* Get a file download URL
|
||||
*/
|
||||
static DownloadURL(file: UploadedFile): string {
|
||||
return APIClient.backendURL() + `/file/${file.id}/download`;
|
||||
static DownloadURL(file: UploadedFile, forceDownload = false): string {
|
||||
return (
|
||||
APIClient.backendURL() +
|
||||
`/file/${file.id}/download${forceDownload ? "?download=true" : ""}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ export function FileViewerDialog(p: {
|
||||
fileName={p.file.file_name}
|
||||
fileSize={p.file.file_size}
|
||||
url={FileApi.DownloadURL(p.file)}
|
||||
downloadUrl={FileApi.DownloadURL(p.file, true)}
|
||||
mimetype={p.file.mime_type}
|
||||
/>
|
||||
<DialogActions>
|
||||
@ -38,6 +39,7 @@ interface ViewerProps {
|
||||
fileName: string;
|
||||
fileSize: number;
|
||||
url: string;
|
||||
downloadUrl: string;
|
||||
mimetype: string;
|
||||
}
|
||||
|
||||
@ -65,7 +67,7 @@ function DefaultViewer(p: ViewerProps): React.ReactElement {
|
||||
<Typography variant="caption" gutterBottom>
|
||||
{filesize(p.fileSize)}
|
||||
</Typography>
|
||||
<a href={p.url} target="_blank" referrerPolicy="no-referrer">
|
||||
<a href={p.downloadUrl} target="_blank" referrerPolicy="no-referrer">
|
||||
<Button variant="outlined">Download</Button>
|
||||
</a>
|
||||
</Paper>
|
||||
|
Reference in New Issue
Block a user