streaming_django.py 454 B

123456789101112131415161718192021222324
  1. # django
  2. from django.http import StreamingHttpResponse
  3. import zipfly
  4. paths = [
  5. {
  6. 'fs': 'home/user/Videos/jupiter.mp4',
  7. 'n': 'movies/jupiter.mp4',
  8. },
  9. ]
  10. # constructor
  11. zfly = zipfly.ZipFly( paths=paths )
  12. # z is a new generator
  13. z = zfly.generator()
  14. # django streaming
  15. response = StreamingHttpResponse(z, content_type='application/octet-stream')
  16. response['Content-Disposition'] = 'attachment; filename=file.zip'
  17. return response