diff --git a/api/src/controllers/assets.ts b/api/src/controllers/assets.ts index bd36b4b650..5aa5bc0865 100644 --- a/api/src/controllers/assets.ts +++ b/api/src/controllers/assets.ts @@ -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); }) ); diff --git a/app/src/modules/files/routes/item.vue b/app/src/modules/files/routes/item.vue index 61288d4a08..35a624ae57 100644 --- a/app/src/modules/files/routes/item.vue +++ b/app/src/modules/files/routes/item.vue @@ -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'); } diff --git a/packages/spec/specs/paths/assets/assets.yaml b/packages/spec/specs/paths/assets/assets.yaml index 8a7873a6b7..46a6b43c50 100644 --- a/packages/spec/specs/paths/assets/assets.yaml +++ b/packages/spec/specs/paths/assets/assets.yaml @@ -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