mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add download query param to assets endpoint
This commit is contained in:
@@ -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);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user