Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
imwhatiam committed Dec 24, 2023
1 parent 63ca110 commit 1f0ef49
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion seahub/seadoc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
from urllib.parse import quote
from django.shortcuts import render
from django.http import HttpResponse
from django.utils.translation import gettext as _

from seaserv import get_repo, seafile_api
Expand Down Expand Up @@ -168,6 +169,7 @@ def sdoc_to_docx(request, repo_id):
return render_error(request, error_msg)

username = request.user.username
filename = os.path.basename(file_path)
doc_uuid = get_seadoc_file_uuid(repo, file_path)
download_token = seafile_api.get_fileserver_access_token(repo_id, file_id,
'download', username)
Expand All @@ -177,4 +179,8 @@ def sdoc_to_docx(request, repo_id):
resp_with_docx_file = sdoc_export_to_docx(file_path, username, doc_uuid,
download_token, src_type, dst_type)

return resp_with_docx_file
docx_mime_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
response = HttpResponse(content_type=docx_mime_type)
response['Content-Disposition'] = f'attachment; filename={filename[:-4]}.docx'
response.write(resp_with_docx_file.content)
return response

0 comments on commit 1f0ef49

Please sign in to comment.