File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
apps/filebrowser/src/filebrowser Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 22
22
import mimetypes
23
23
import posixpath
24
24
from io import BytesIO as string_io
25
+ from urllib .parse import quote
25
26
26
27
from django .core .files .uploadhandler import StopUpload
27
28
from django .core .paginator import EmptyPage , Paginator
@@ -224,7 +225,14 @@ def download(request):
224
225
request .GET .get ('disposition' ) if request .GET .get ('disposition' ) == 'inline' and _can_inline_display (path ) else 'attachment'
225
226
)
226
227
227
- response ['Content-Disposition' ] = f'{ content_disposition } ; filename="{ stats ["name" ]} "'
228
+ # Extract filename for HDFS and OFS for now because the path stats object has a bug in fetching name field
229
+ # TODO: Fix this super old bug when refactoring the underlying HDFS filesystem code
230
+ filename = os .path .basename (path ) if request .fs ._get_scheme (path ).lower () in ('hdfs' , 'ofs' ) else stats ['name' ]
231
+
232
+ # Set the filename in the Content-Disposition header with proper encoding for special characters
233
+ encoded_filename = quote (filename )
234
+ response ['Content-Disposition' ] = f"{ content_disposition } ; filename*=UTF-8\' \' { encoded_filename } "
235
+
228
236
response ["Last-Modified" ] = http_date (stats ['mtime' ])
229
237
response ["Content-Length" ] = stats ['size' ]
230
238
You can’t perform that action at this time.
0 commit comments