Skip to content
Snippets Groups Projects
Commit 3793dc8a authored by Xiao Gui's avatar Xiao Gui
Browse files

chore: allow downloading of autoradiographs

parent 6a90e354
No related branches found
No related tags found
No related merge requests found
......@@ -132,6 +132,12 @@ datasetsRouter.get('/previewFile', cacheMaxAge24Hr, (req, res) => {
const { file } = req.query
const filePath = previewFileMap.get(file)
// Set content type to give browser a hint for download
const ext = path.extname(filePath).slice(1)
const type = express.static.mime.types[ext]
if (type) res.setHeader('Content-Type', type)
// even though req.url is modified, req.query is not
// for now, just serve non encoded image
......
......@@ -32,7 +32,10 @@ export class FileViewer implements OnChanges{
private cdr: ChangeDetectorRef,
@Optional() @Inject(MAT_DIALOG_DATA) data
){
if (data) this.previewFile = data.previewFile
if (data) {
this.previewFile = data.previewFile
this.downloadUrl = this.previewFile.url
}
}
public downloadUrl: string
......
......@@ -86,6 +86,10 @@
<i class="fas fa-file-csv"></i>
</a>
<!-- nb -->
<!-- cross origin download attribute will be ignored -->
<!-- this effective means that when dev on localhost:8080, resource request to localhost:3000 will always open in a new window -->
<!-- link: https://developers.google.com/web/updates/2018/02/chrome-65-deprecations#block_cross-origin_wzxhzdk5a_download -->
<a mat-icon-button
*ngIf="downloadUrl"
[href]="downloadUrl"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment