Hello,

by the way, if anyone uses Nginx, there's nearly the same with

X-Accel-redirect headers
http://wiki.nginx.org/XSendfile


Romain



On Thu, May 26, 2011 at 7:08 PM, Bart van Wissen <bartvanwis...@gmail.com>wrote:

> On 11 mei, 11:24, David Buchmann <david.buchm...@liip.ch> wrote:
> > hi,
> >
> > i have binary content that i have to deliver to the client. what is the
> > right way to do it? i found two solutions, but neither seems really good.
> >
> > //in my controller, i get a binary stream (its stored in the database)
> >
> > $picture = $this->method_that_returns_resource_stream();
> >
> > // i can just use plain php and dump and die. not nice.
> > header('Content-Type: image/jpeg');
> > fpassthru($picture);
> > die;
> >
> > /*
> > or i can use a response, but then i have to read the stream into memory,
> > which is unefficient.
> > */
> >
> > $response = new Response(stream_get_contents($picture));
> > $response->headers->set('Content-Type', 'image/jpeg');
> > return $response;
> >
>
> You should take a look at mod_xsendfile (assuming you're using
> apache).
>
> https://tn123.org/mod_xsendfile/
>
> You can then let apache take care of actually sending the file.
> All you have to do is send a response-header like this:
>
> X-Sendfile: /path/to/the/file
>
> The module will intercept this header and send the file.
>
>
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to