Merge pull request #5999 from jumpserver/pr@dev@fix_rdp_file_addr

fix: 修复下载rdp文件失败的问题
pull/6000/head
老广 2021-04-20 03:28:34 -05:00 committed by GitHub
commit 4a4d5f3243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
#
import urllib.parse
from django.conf import settings
from django.core.cache import cache
from django.shortcuts import get_object_or_404
@ -148,7 +150,8 @@ class UserConnectionTokenViewSet(RootOrgViewMixin, SerializerMixin2, GenericView
data += f'{k}:{v}\n'
response = HttpResponse(data, content_type='application/octet-stream')
filename = "{}-{}-jumpserver.rdp".format(user.username, asset.hostname)
response['Content-Disposition'] = 'attachment; filename={}'.format(filename)
filename = urllib.parse.quote(filename)
response['Content-Disposition'] = 'attachment; filename*=UTF-8\'\'%s' % filename
return response
@staticmethod