Comments (4)
@filwaline that's an interesting question. Do you have a way to fix this in mind?
from django-downloadview.
use @contextlib.contextmanager
@contextlib.contextmanager
def get_file(self):
fileobject = open(...)
try:
yield fileobject
finally:
fileobject.close()
try:
with self.get_file() as f:
self.file_instance = f
# Respect the If-Modified-Since header.
since = self.request.META.get("HTTP_IF_MODIFIED_SINCE", None)
if since is not None:
if not self.was_modified_since(self.file_instance, since):
return self.not_modified_response(**response_kwargs)
# Return download response.
return self.download_response(*response_args, **response_kwargs)
except exceptions.FileNotFound:
return self.file_not_found_response()
https://github.com/jazzband/django-downloadview/blob/master/django_downloadview/views/base.py#L144
code not tested, but it should work
from django-downloadview.
Do you mind creating a pull-request with your fix?
from django-downloadview.
Maybe later
from django-downloadview.
Related Issues (20)
- Dead package
- Drop support for Python 2.7 and Django 1.11
- Proposal to move django-downloadview to JazzBand. HOT 3
- mI got the following error while running the demo with "make runserver":django.db.utils.OperationalError: Problem installing fixture '/home/ruihai.jing/TTProgram/django-downloadview-master/demo/demoproject/fixtures/demo.json': Could not load object.Document(pk=1): no such table: object_document HOT 1
- Implement Jazzband guidelines for django-downloadview HOT 5
- Documentation references end of life Python 2.7
- Remove setuptools install_requires entry
- Demo project has settings for end of life Django versions HOT 1
- DjangoRestFramework Integration HOT 4
- Document integration of ObjectDownloadView with NGINX acceleration HOT 12
- Migrating from django-sendfile HOT 2
- Support Django 4.0 HOT 2
- Please make a new pypi release to support Django 4 HOT 1
- Add Async Support HOT 3
- Use Django's built-in FileResponse to address security issue HOT 1
- Very slow download speed from `ObjectDownloadView` HOT 3
- Signal/event once file has been downloaded? HOT 2
- How to use django-downloadview for ensuring only authenticated users can access media files? HOT 2
- Preserve headers of original response
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-downloadview.