Add download query param to assets endpoint

This commit is contained in:
rijkvanzanten
2020-10-19 12:45:10 -04:00
parent 552fbff5ed
commit 0f20f9ea7c
3 changed files with 14 additions and 5 deletions

View File

@@ -119,6 +119,10 @@ router.get(
res.attachment(file.filename_download);
res.setHeader('Content-Type', file.type);
if (req.query.hasOwnProperty('download') === false) {
res.removeHeader('Content-Disposition');
}
stream.pipe(res);
})
);

View File

@@ -395,7 +395,7 @@ export default defineComponent({
}
function downloadFile() {
const filePath = getRootPath() + `assets/${props.primaryKey}`;
const filePath = getRootPath() + `assets/${props.primaryKey}?download`;
window.open(filePath, '_blank');
}

View File

@@ -17,29 +17,34 @@ get:
description: The key of the asset size configured in settings.
schema:
type: string
- name: w
- name: width
in: query
description: Width of the file in pixels.
schema:
type: integer
- name: h
- name: height
in: query
description: Height of the file in pixels.
schema:
type: integer
- name: f
- name: fit
in: query
description: Fit of the file
schema:
type: string
enum: [crop, contain]
- name: q
- name: quality
in: query
description: Quality of compression.
schema:
type: integer
minimum: 1
maximum: 100
- name: download
in: query
description: Download the asset to your computer
schema:
type: boolean
responses:
"200":
description: Successful request