Ejemplo n.º 1
0
 def get(self, request, *args, **kwargs):
     if self.revision:
         try:
             return send_file(request, self.revision.file.path, 
                              self.revision.created, self.attachment.original_filename)
         except OSError:
             pass
     raise Http404
Ejemplo n.º 2
0
 def get(self, request, *args, **kwargs):
     if self.revision:
         try:
             return send_file(request, self.revision.file.path,
                              self.revision.created,
                              self.attachment.original_filename)
         except OSError:
             pass
     raise Http404
Ejemplo n.º 3
0
 def test_send_file(self):
     fabricate_request = self.client.get("/").wsgi_request
     fobject = tempfile.NamedTemporaryFile("r")
     response = send_file(fabricate_request,
                          fobject.name,
                          filename="test.pdf")
     assert response.has_header("Content-Disposition")
     assert "inline" in response.get("Content-Disposition")
     response = send_file(fabricate_request,
                          fobject.name,
                          filename="test.jpeg")
     assert response.has_header("Content-Disposition")
     response = send_file(fabricate_request,
                          fobject.name,
                          filename="test.jpeg",
                          last_modified=datetime.now())
     assert response.has_header("Content-Disposition")
     fobject.close()
Ejemplo n.º 4
0
 def get(self, request, *args, **kwargs):
     if self.revision:
         if settings.USE_LOCAL_PATH:
             try:
                 return send_file(request, self.revision.file.path, 
                                  self.revision.created, self.attachment.original_filename)
             except OSError:
                 pass
         else:
             return HttpResponseRedirect(self.revision.file.url)
     raise Http404
Ejemplo n.º 5
0
 def get(self, request, *args, **kwargs):
     if self.revision:
         if settings.USE_LOCAL_PATH:
             try:
                 return send_file(request, self.revision.file.path, 
                                  self.revision.created, self.attachment.original_filename)
             except OSError:
                 pass
         else:
             return HttpResponseRedirect(self.revision.file.url)
     raise Http404
Ejemplo n.º 6
0
    def get(self, request, *args, **kwargs):
        if self.revision:
            if settings.USE_LOCAL_PATH:
                from django.core.files.storage import default_storage as storage
                from django.conf import settings as django_settings

                f = storage.open(self.revision.file.name)
                if "amazonaws" in django_settings.STATIC_URL:
                    path = django_settings.MEDIA_URL + f.name
                else:
                    path = self.revision.file.path
                try:
                    return send_file(request, path, self.revision.created, self.attachment.original_filename)
                except OSError:
                    pass
            else:
                return HttpResponseRedirect(self.revision.file.url)
        raise Http404