What you have seems correct but we do not get the whole picture from this
code. Sorry.
On Sunday, 11 September 2016 04:52:24 UTC-5, Joe Barnhart wrote:
>
> This MUST be something I'm doing wrong. I have used this very code --
> even this method -- countless times but now it fails to stream the file.
> The object being streamed is a StringIO buffer of some file that I create
> on the fly. I'm trying to download it with a provided file name and type.
> This code has worked in the past, but I've been hammering on my site
> getting it "updated" and now it streams the word "None" every time.
>
> If I stop and debug the buffer, I can see about 97K worth of text queued
> up and ready to go. I've stepped it as far as the Response.stream() method
> and everything looks perfect. But when the rubber hits the road, all I get
> is "None". Here is the my code:
>
> def _reg_getfile(now,idset):
> from regexport import generate_regfile
> from cStringIO import StringIO
> buf = StringIO()
> generate_regfile(idset, buf)
> buf.seek(0)
> response.headers['Content-Type']='application/sd3'
> response.headers['Content-Disposition']='attachment;
> filename=reg-%s.sd3'%now.strftime('%y%m%d-%H%M%S')
> return response.stream(buf)
>
> And my response in a file named reg-160911-023542.sd3:
>
> None
>
> Help me prevent baldness here. Because I'm sure I'm going to tear my hair
> out over this!
>
> I'm using "Version 2.14.6-stable+timestamp.2016.05.09.19.18.48" and Python
> 2.7.12 on a Mac under El Capitan (OS X ver. 10.11.6). I"ve tried Safari,
> Chrome, and FireFox with the same result.
>
> -- Joe
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.