Comments (4)
basename is an attribute of the download response. Can be different from file's name.
from django-downloadview.
Some examples...
Use case: stream a file which exists on disk.
- django.core.files.File is a suitable wrapper.
- provides "name" attribute
- provides iterator over file contents.
Use case: a file that lives in some model, using a storage.
- model's FieldFile is a suitable wrapper
- optionally provides "url" attribute, depending on storage implementation
- optionally provides "name" attribute, depending on storage implementation
- provides iterator over file contents.
Use case: generate and stream a CSV file without writing it to disk:
- needs a suitable file wrapper
- doesn't provide url or name
- provides iterator over file contents
=> The iterator over file contents seems to be the only mandatory requirement.
=> name and url are optional. Even if they seem recommended for server optimizations (Django could write in a temporary file, but this is not the best optimization).
=> size is recommended, but optional. If "name" is provided, then size can be computed with os.stat. If URL is provided, size could be useful, but in case of server optimizations, the server may be able to add the content-length header. If the file is a virtual one (dynamic streaming), then it seems difficult to provide a size before the whole file contents is iterated. Does the lack of "Content-Length" compromise the download?
=> content_type, mime_type, charset and maybe some other attributes are optional: they can be computed by the response class. However, if they are provided, we should use them, because it allows optimizations and customizations.
=> modification_time seems useful, but could be optional (could default to "always new").
from django-downloadview.
Django's storage API provides "modified_time" (not "modification_time"), "accessed_time" and "created_time".
from django-downloadview.
In Django's storage API (and thus FieldFiles), file wrappers have:
- name: filename which could be relative or absolute. It is a value used to open the file (with open() in case of a local file, with the storage in case of a FieldFile).
- path: absolute local filename. Not provided if storage doesn't support usage of Python builtin open()
=> The difference seems important. Let's keep this design.
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.