Pārlūkot izejas kodu

Download of specific file added

Jérôme BUISINE 4 gadi atpakaļ
vecāks
revīzija
00bfdab0b1
1 mainītis faili ar 8 papildinājumiem un 3 dzēšanām
  1. 8 3
      expe/views.py

+ 8 - 3
expe/views.py

@@ -214,16 +214,21 @@ def download_result(request):
             zf.close()
             zf.close()
 
 
             output_filename = zip_filename
             output_filename = zip_filename
+            content = s.getvalue()
 
 
         else:
         else:
             
             
+            with open(folder_path, 'rb') as f:
+                content = f.readlines()
+
             # filename only
             # filename only
-            output_filename = folder_path
+            fdir, fname = os.path.split(path)
+            output_filename = fname
 
 
         # Grab ZIP file from in-memory, make response with correct MIME-type
         # Grab ZIP file from in-memory, make response with correct MIME-type
-        resp = HttpResponse(s.getvalue(), content_type="application/gzip")
+        resp = HttpResponse(content, content_type="application/gzip")
         # ..and correct content-disposition
         # ..and correct content-disposition
-        resp['Content-Disposition'] = 'attachment; filename=%s' % zip_filename
+        resp['Content-Disposition'] = 'attachment; filename=%s' % output_filename
 
 
         return resp
         return resp