{"comment":{"created_at":"2011-10-10T13:27:49Z","body":"This is the standard way of sending back files in django:\r\n\r\n    from django.core.files.temp import NamedTemporaryFile\r\n    def send_file(request):\r\n        newfile = NamedTemporaryFile()\r\n        ...\r\n        wrapper = FileWrapper(newfile)\r\n        response = HttpResponse(wrapper, content_type=mime_type)\r\n        response['Content-Disposition'] = 'attachment; filename=%s' % newfile.name\r\n        response['Content-Length'] = newfile.tell()\r\n        return response\r\n\r\nNamedTemporaryFile should be deleted once the newfile object is evicted. When you step out of the send_file function, there should be no more reference to the newfile object, but it's not guaranteed that the object will be garbage-collected and its del method called. From the other hand I am not aware about any built-in mechanism to automatically delete TemporaryFile instances within HttpRespons.\r\n\r\nI got ride of some of NamedTemporaryFile becuse we are `yielding` OriginalFile and this can write directly to HttpResponse, but there are still two cases where: multiple files are zipped and mrc map is asking for real file.\r\n","updated_at":"2011-10-10T13:27:49Z","url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/comments/2347319","id":2347319,"user":{"avatar_url":"https://secure.gravatar.com/avatar/0a34426a83a7f566547dad5bd4d27b9c?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/aleksandra-tarkowska","id":1065155,"login":"aleksandra-tarkowska"}},"action":"created","issue":{"number":7,"created_at":"2011-10-10T13:26:20Z","pull_request":{"diff_url":"https://github.com/openmicroscopy/openmicroscopy/pull/7.diff","patch_url":"https://github.com/openmicroscopy/openmicroscopy/pull/7.patch","html_url":"https://github.com/openmicroscopy/openmicroscopy/pull/7"},"body":"Please, pull those bug fixes 4.3.3 to develop.","comments":1,"title":"4.3.3 bugs","updated_at":"2011-10-10T13:27:49Z","url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/7","id":1864004,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/0a34426a83a7f566547dad5bd4d27b9c?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/aleksandra-tarkowska","id":1065155,"login":"aleksandra-tarkowska"},"html_url":"https://github.com/openmicroscopy/openmicroscopy/issues/7","labels":[],"state":"open"},"legacy":{"issue_id":1864004,"comment_id":2347319}}