Как получить имя того же файла, загруженного как Response, при загрузке в python Django
Я загрузил и скачал файл. Я не получаю имя файла, который я загрузил, когда я его скачал. Я пытаюсь программировать на python Django, есть ли какое-нибудь решение, чтобы решить это.
def mDownloadResume(request, userid):
profile = UserProfile.objects.get(id=userid)
ts = profile.up_auth_user_id
resumefilename = Resume.objects.get(rs_auth_user_id=ts)
uploadName = resumefilename.rs_original_name
user_id = resumefilename.rs_auth_user_id
savedFile= resumefilename.rs_saved_name
contentype = "application/pdf"
filepath = os.path.join(BASE_DIR , "Resume", savedFile)
if os.path.exists(filepath):
with open(filepath, 'rb') as fh:
response = HttpResponse(fh.read(), content_type=contentype)
response['Content-Disposition'] = 'inline; filename=' +os.path.basename(filepath) \
return response
raise Http404