Comments (5)
I'm not sure this will work. sendfile is just a very thin wrapper that normally just sets a header to get nginx, apache etc to do the real work - which is much better for performance. They expect a "real" file path and won't be able to deal with a file wrapper (as that's a python concept).
The sendfile wrapper is merely a layer to smooth over the differences between the xsendfile/accellredirect stuff (as well as providing something to use during development).
If you want to use a file wrapper you might as well just return a regular Django HttpResponse with the contents of the file.
from django-sendfile.
This "file wrapper" feature is supported by django-downloadview version 1.1. It works ;)
If you want to use a file wrapper you might as well just return a regular Django HttpResponse with the contents of the file.
That's the way it is implemented in django-downloadview: the view returns some DownloadResponse (inherits from StreamingHttpResponse), which can be intercepted by middlewares (x-accel, x-sendfile...) before it is loaded into memory.
In #9 you said:
I don't think it really makes sense to merge the projects, but it would possibly make sense for django-downloadview to use django-sendfile, as django-sendfile is really just a small building block.
As of django-sendfile version 0.3.2 and django-downloadview version 1.1, django-downloadview has poor interest using django-sendfile, because django-downloadview can serve files that don't live in local filesystem. It could use django-sendfile to serve local files, but would have to re-implement (duplicate) most things to support remote files.
That said, I asked here because I feel that it would be useful for both projects to exchange some features. This "file wrapper" feature is one example that could be moved from django-downloadview to django-sendfile. Then, perhaps, django-downloadview could use django-sendfile.
But feel free to discard this issue if you don't want to change sendfile()
signature ; I would understand this opinion :)
from django-sendfile.
Note: I'll be at europython (Florence) and djangocon.eu (Warsaw) this year... if you or some django-sendfie contributor are there too and would like to discuss/sprint in real life ;)
from django-sendfile.
Hi Benoit,
sendfile is really just concerned with local files - it's intended to get apache/nginx to use the OS's sendfile (http://linux.die.net/man/2/sendfile) call for maximum efficiency. It's purely an optimisation, though when serving file that is several Mb (or possibly even several Gb) in size it can make a difference.
Supporting file wrappers would not allow for this optimisation, which would defeat the purpose of using the library in the first place.
The scope of sendfile is much smaller than what you seem to be trying to achieve with django-downloadview. It really is just meant to be a very small, very simple library to paper over the differences between using nginx or xsendfile (and the django dev server).
In #9 I wasn't suggesting that you should use django-sendfile, just that you could - just detect whether you're serving a real file or a wrapper and call sendfile if it's a real file. If done right I don't imagine you'd need much/any duplication in your code - only the point at which you return a HttpResponse should changed really. It looks like you already support nginx etc anyway?
So yeah, I guess it's a polite no from me on supporting file wrappers ...
cheers,
John
p.s. sorry, won't be going to either of those conferences I'm afraid.
from django-sendfile.
I guess it's a polite no from me on supporting file wrappers
Ok, not a big deal ;)
Let's close the issue.
It looks like you already support nginx etc anyway?
Yes. Only nginx for now. And that's a reason why I'm looking at using django-sendfile and its backends.
sendfile is really just concerned with local files
That's the main point imho.
Django-downloadview supports both (local) filenames and (remote or local) URL. The latter relies on nginx's configuration, i.e. using "root" for local files, whereas using "proxy_pass" for URL.
won't be going to either of those conferences
Maybe another day, in another place...
from django-sendfile.
Related Issues (20)
- mod_wsgi backend broken on Django 1.8 HOT 9
- Our abc.tar.gz file sent using this django-sendfile was automatically getting unzipped by the browser
- Release 0.3.8 HOT 2
- Licensing HOT 4
- Problem with unicode characters HOT 10
- PyPi page looks strange HOT 2
- Is status really "Beta"? HOT 5
- Content-Disposition: Output contains buffer repr (Python 3.4) HOT 1
- Django 1.9 support HOT 4
- How to make "private" media accessible by site staff? HOT 1
- Add tests running in CI
- Support wheel packaging
- Serve a folder with sendfile
- Simple backend will decompress file HOT 1
- Maintaining the project HOT 12
- Apache 2.4 EnableSendfile as a potential replacement for XSendfile HOT 3
- I have to append `media/` to the path to not get a 404
- How to override the image url / path?
- Django 2.1 and above has removed the permalink() decorator HOT 1
- Please redirect to django-sendfile2
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-sendfile.