1

In my production have folder to store the log file. I want to make the html page to download 'log file' (large .txt file, around 1.5 gb/file) from server to client computer using Django (python) views. What is the best solution to do that (no lose data in downloaded file, good performance)

now i use this code but the size of downloaded file is less than the original file in the server :C

with open(file_path, 'rb') as fh:
    response = HttpResponse(fh.read(), content_type="application/force-download")
    response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
    return response
Fah Nateecha
  • 151
  • 3
  • 14
  • Please take a look - https://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files, might be useful – Vivek Sable Mar 05 '20 at 05:03
  • https://djangosnippets.org/snippets/365/ - have a look – Vivek Sable Mar 05 '20 at 05:04
  • maybe you should use FTP or SSH instead web page. – furas Mar 05 '20 at 06:16
  • BTW: some tools can resume downloading after loosing connection and they can use [HTTP/Range_requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests) to asks for data from some range - so they don't have to download again all from beginning. OR they can use it to download at the same different ranges in separated thread. But web page may have to check if client ask for some range. It can be usefull when you have big file to download. – furas Mar 05 '20 at 06:28
  • BTW: Using ZIP file you could make this file smaller and uncompressing it you will get warning if file is broken. Without ZIP or some control codes you don't know if data are correct. – furas Mar 05 '20 at 06:28

0 Answers0