Easiest way is to not do it :)  I try to offload downloads/uploads to a service 
like S3.  Let somebody else do the heavy lifting.  If authentication is needed, 
I’ll generate a presigned URL in Pyramid and redirect.

AFAIA, Accept-Ranges is the only real HTTP solution for resumable/multipart 
downloads.

If you’re using nginx in front of gunicorn (which you should be), you can have 
nginx cache the response and handle Range for you.  
https://www.nginx.com/blog/smart-efficient-byte-range-caching-nginx/ 
<https://www.nginx.com/blog/smart-efficient-byte-range-caching-nginx/>  You 
could also skip Pyramid altogether and serve file directly with nginx, using 
the auth_request module if you need auth.  
https://nginx.org/en/docs/http/ngx_http_auth_request_module.html 
<https://nginx.org/en/docs/http/ngx_http_auth_request_module.html> 

If none of that is feasible, rolling your own FileResponse that handles Range 
shouldn’t be too difficult, although personally that’d be my very last option.

— Theron



> On Jun 28, 2022, at 1:01 PM, Mikko Ohtamaa <[email protected]> wrote:
> 
> Hi,
> 
> What would be an easy way to support partial downloads / resumes with 
> Pyramid? Namely HTTP Accept Ranges come to my mind, but there could be others.
> 
> - Serving files directly from FS using FileResponse
> 
> - Using gunicorn as a web server
> 
> https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5 
> <https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5>
> 
> Br,
> Mikko
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUurRhwaqBem%3DVi3OEYWw-oMZh0fhRqCqZcjPiGibyO8Rw%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUurRhwaqBem%3DVi3OEYWw-oMZh0fhRqCqZcjPiGibyO8Rw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/17B77CDE-936B-488E-809B-19ADDA179A50%40luhn.com.

Reply via email to