fix(server): correctly handle content-disposition (#5008)
- non-ascii filenames were not handled correctly causing 500 errors when file attempted to be downloaded
This commit is contained in:
@@ -30,6 +30,7 @@ import { getStreamFactory } from '@/modules/core/repositories/streams'
|
||||
import { processNewFileStreamFactory } from '@/modules/blobstorage/services/streams'
|
||||
import { UserInputError } from '@/modules/core/errors/userinput'
|
||||
import { createBusboy } from '@/modules/blobstorage/rest/busboy'
|
||||
import contentDisposition from 'content-disposition'
|
||||
|
||||
export const blobStorageRouterFactory = (): Router => {
|
||||
const processNewFileStream = processNewFileStreamFactory()
|
||||
@@ -136,7 +137,7 @@ export const blobStorageRouterFactory = (): Router => {
|
||||
})
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Disposition': `attachment; filename="${fileName}"`
|
||||
'Content-Disposition': contentDisposition(fileName)
|
||||
})
|
||||
fileStream.pipe(res)
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"busboy": "^1.4.0",
|
||||
"compression": "^1.7.4",
|
||||
"connect-redis": "^6.1.1",
|
||||
"content-disposition": "^0.5.4",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cors": "^2.8.5",
|
||||
"cross-fetch": "^3.1.5",
|
||||
@@ -155,6 +156,7 @@
|
||||
"@types/chai-as-promised": "^7.1.8",
|
||||
"@types/compression": "^1.7.2",
|
||||
"@types/connect-redis": "^0.0.23",
|
||||
"@types/content-disposition": "^0.5.9",
|
||||
"@types/cookie-parser": "^1.4.7",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/debug": "^4.1.7",
|
||||
|
||||
@@ -16084,6 +16084,7 @@ __metadata:
|
||||
"@types/chai-as-promised": "npm:^7.1.8"
|
||||
"@types/compression": "npm:^1.7.2"
|
||||
"@types/connect-redis": "npm:^0.0.23"
|
||||
"@types/content-disposition": "npm:^0.5.9"
|
||||
"@types/cookie-parser": "npm:^1.4.7"
|
||||
"@types/cors": "npm:^2.8.17"
|
||||
"@types/debug": "npm:^4.1.7"
|
||||
@@ -16132,6 +16133,7 @@ __metadata:
|
||||
compression: "npm:^1.7.4"
|
||||
concurrently: "npm:^7.0.0"
|
||||
connect-redis: "npm:^6.1.1"
|
||||
content-disposition: "npm:^0.5.4"
|
||||
cookie-parser: "npm:^1.4.6"
|
||||
cors: "npm:^2.8.5"
|
||||
cross-env: "npm:^7.0.3"
|
||||
@@ -18694,6 +18696,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/content-disposition@npm:^0.5.9":
|
||||
version: 0.5.9
|
||||
resolution: "@types/content-disposition@npm:0.5.9"
|
||||
checksum: 10/d895703c0027ca6c4c0c1ede363909dbb590deec3b206a84b88a49c8b2840bcbd31b4ddeb2e1e6caa1af00801cc79c5b69a5c75a8152f2959810b10fe75a4e1f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/cookie-parser@npm:^1.4.7":
|
||||
version: 1.4.7
|
||||
resolution: "@types/cookie-parser@npm:1.4.7"
|
||||
|
||||
Reference in New Issue
Block a user