fix: 修复app无法下载xrdp文件

pull/6319/head
ibuler 2021-06-17 13:20:34 +08:00 committed by 老广
parent 8d25d0a653
commit 053d958f9a
1 changed files with 7 additions and 1 deletions

View File

@ -155,8 +155,14 @@ class UserConnectionTokenViewSet(RootOrgViewMixin, SerializerMixin2, GenericView
data = ''
for k, v in options.items():
data += f'{k}:{v}\n'
if asset:
name = asset.hostname
elif application:
name = application.name
else:
name = '*'
response = HttpResponse(data, content_type='application/octet-stream')
filename = "{}-{}-jumpserver.rdp".format(user.username, asset.hostname)
filename = "{}-{}-jumpserver.rdp".format(user.username, name)
filename = urllib.parse.quote(filename)
response['Content-Disposition'] = 'attachment; filename*=UTF-8\'\'%s' % filename
return response