Comments (3)
This feature may be implemented as follow:
- "global backend" is configured in middlewares, as
DOWNLOADVIEW_MIDDLEWARES
items. This is not a single backend, but a set of backends. At least they are registered in a single location: settings. - the recommended practice (in documentation) is to use the global middlewares.
- where you explicitely want a decorator and you do not want to care about the backend, you can use some generic decorator, which accepts most common backend arguments: source URL or path and destination URL.
- where you explicitely want a decorator and you care about the backend, you can use a specific decorator, or a specific list of "middlewares" that can capture the response.
=> DOWNLOADVIEW_MIDDLEWARES
makes most use cases easy.
=> Custom decorators allow fine-tuning for specific needs.
from django-downloadview.
Note about the previous comment...
"Download decorators" were introduced mostly to support multiple backend configurations. As of version 1.2, you cannot setup multiple (source, destination) rules for one middleware. So you actually have to setup per-view configuration via decorators.
With DOWNLOAD_MIDDLEWARES
setting (a list of middlewares with initialization arguments), you can have multiple rules for a given backend. So decorators are no longer the easier way to go.
from django-downloadview.
Created #50 about multiple configuration support.
This ticket may not be resolved in version 1.3.
After #50 is resolved, a solution could be to create some "generic" middleware that accept a backend as argument (or use global "DOWNLOADVIEW_BACKEND" setting) and use sane defaults for backend-specific options.
Then we could have only one middleware class (or backend) and several "rewrite rules" for it.
Something like TRANSFER_MAPPINGS
in https://github.com/smartfile/django-transfer/
MIDDLEWARE_CLASSES = [
'django_downloadview.DownloadDispatcherMiddleware',
]
DOWNLOADVIEW_BACKEND = 'django_downloadview.nginx.XAccelRedirectMiddleware'
DOWNLOADVIEW_RULES = [
(MEDIA_URL, '/optimized-download/'), # *args
{'source_url': MEDIA_URL, 'destination_url': '/optimized-download', 'limit_rate': 32}, # kwargs, with specific options
]
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
- Did this module ever close a file? HOT 4
- 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.