Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix download filename on Safari

Chocobozzz8500ca679d04
diff --git a/package.json b/package.json
index f97186fa6a..a542f64227 100644
--- a/package.json
+++ b/package.json
@@ -135,6 +135,7 @@
"chokidar": "^4.0.3",
"commander": "^14.0.2",
"config": "^4.1.1",
+ "content-disposition": "^1.0.1",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"create-torrent": "^6.1.0",
@@ -216,6 +217,7 @@
"@types/chai-json-schema": "^1.4.10",
"@types/chai-xml": "^0.3.6",
"@types/config": "^3.3.5",
+ "@types/content-disposition": "^0.5.9",
"@types/create-torrent": "^5.0.2",
"@types/express": "4.17.9",
"@types/express-serve-static-core": "4.19.5",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8cc29c5b48..649648a51a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -158,6 +158,9 @@ importers:
config:
specifier: ^4.1.1
version: 4.1.1
+ content-disposition:
+ specifier: ^1.0.1
+ version: 1.0.1
cookie-parser:
specifier: ^1.4.7
version: 1.4.7
@@ -396,6 +399,9 @@ importers:
'@types/config':
specifier: ^3.3.5
version: 3.3.5
+ '@types/content-disposition':
+ specifier: ^0.5.9
+ version: 0.5.9
'@types/create-torrent':
specifier: ^5.0.2
version: 5.0.2
@@ -3742,6 +3748,9 @@ packages:
resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-8uYXI3Gw35MhiVYhG3s295oihrxRyytcRHjSjqnqZVDDy/xcGBRny7+Xj1Wgfhv5QzRtN2hB2dVRBUX9XW3UcQ==}
+
resolution: {integrity: sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==}
@@ -5145,6 +5154,10 @@ packages:
resolution: {integrity: sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==}
engines: {node: '>= 0.6'}
+ resolution: {integrity: sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==}
engines: {node: '>= 0.6'}
@@ -14122,6 +14135,8 @@ snapshots:
dependencies:
'@types/node': 22.14.1
+ '@types/[email protected]': {}
+
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -15657,7 +15672,7 @@ snapshots:
dependencies:
- follow-redirects: 1.15.11
+ follow-redirects: 1.15.11([email protected])
transitivePeerDependencies:
- debug
@@ -15979,6 +15994,8 @@ snapshots:
dependencies:
safe-buffer: 5.2.1
+
@@ -17419,8 +17436,6 @@ snapshots:
-
optionalDependencies:
debug: 4.4.3([email protected])
diff --git a/server/core/controllers/download.ts b/server/core/controllers/download.ts
index 54bdbf9b41..a9b4274e08 100644
--- a/server/core/controllers/download.ts
+++ b/server/core/controllers/download.ts
@@ -23,6 +23,7 @@ import {
MVideoFullLight
} from '@server/types/models/index.js'
import { MVideoSource } from '@server/types/models/video/video-source.js'
+import contentDisposition from 'content-disposition'
import cors from 'cors'
import express from 'express'
import { DOWNLOAD_PATHS, WEBSERVER } from '../initializers/constants.js'
@@ -264,7 +265,7 @@ async function downloadGeneratedVideoFile (req: express.Request, res: express.Re
const urlPath = new URL(req.originalUrl, WEBSERVER.URL).pathname
if (!urlPath.endsWith('.mp4') && !urlPath.endsWith('.m4a')) {
const downloadFilename = buildDownloadFilename({ video, extname })
- res.setHeader('Content-disposition', `attachment; filename="${encodeURI(downloadFilename)}`)
+ res.setHeader('Content-disposition', contentDisposition(encodeURI(downloadFilename)))
}
res.type(extname)