Removing tmp file after return HttpResponse in django

后端 未结 6 669
长情又很酷
长情又很酷 2020-12-11 03:06

I\'m using the following django/python code to stream a file to the browser:

wrapper = FileWrapper(file(path))
response = HttpResponse(wrapper, content_type=         


        
6条回答
  •  -上瘾入骨i
    2020-12-11 04:10

    One way would be to add a view to delete this file and call it from the client side using an asynchronous call (XMLHttpRequest). A variant of this would involve reporting back from the client on success so that the server can mark this file for deletion and have a periodic job clean it up.

提交回复
热议问题