This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

How to use Xsendfile with sf?

This is for discussion, mainly on 1.x but there's some 2.x topics here too.

How to use Xsendfile with sf?

by c.nicos » Sat Sep 11, 2010 5:04 pm

I want to serve some large files using xendfile, but can't get it working with sf.
Can any body give some clues, please?
c.nicos
Junior Member
 
Posts: 4
Joined: Fri Jan 22, 2010 3:45 am
Location: Beijing, China

Re: How to use Xsendfile with sf?

by c.nicos » Sat Sep 11, 2010 5:21 pm

os: CentOS 5 x86
sf version: 1.4.6

I added the XSendFilePath in the <VirtualHost> section in the httpd.conf

in the actions.class.php I use something like:
...
if(!file_exists($path))
$this->forward404();

$this->getResponse()->clearHttpHeaders();
header("X-Sendfile: $path");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment: filename=\"$filename\"");

return sfView::NONE;

the browser can start the download, but the file downloaded is always 0 byte big...

Please help me.
c.nicos
Junior Member
 
Posts: 4
Joined: Fri Jan 22, 2010 3:45 am
Location: Beijing, China

Re: How to use Xsendfile with sf?

by claudia_k » Sat Sep 11, 2010 11:04 pm

Did you set XSendFile to On?

What happens if you try the same request in some php script on the same server, but outside of symfony?

If possible also check your apache logs - maybe you can find some useful information there.

Good luck

Claudia
claudia_k
Faithful Member
 
Posts: 265
Joined: Mon Jun 21, 2010 8:12 pm
Location: Luxembourg

Re: How to use Xsendfile with sf?

by c.nicos » Sun Sep 12, 2010 5:26 am

Many thanks to claudia_k !
I added a line in the httpd.conf :
XSendFile On
Now it seems to work.
But then I add something like :
XSendFileAllowAbove On
Apache will not start saying the "XSendFileAllowAbove" is not a valid param sort thing.
As noted in the XSendFile doc, the "XSendFileAllowAbove" is used for allowing download files in the parant dirs, and I thought that is the case of symfony, since the actions.class.php is in some child dirs by default.

Anyway, It works for now, and I'll leave it right there. Hope the "XSendFileAllowAbove" thing will not bring me any trouble. :?~:-?~:???:
c.nicos
Junior Member
 
Posts: 4
Joined: Fri Jan 22, 2010 3:45 am
Location: Beijing, China

Re: How to use Xsendfile with sf?

by pisicaroz » Wed Feb 26, 2014 12:38 pm

c.nicos wrote:Many thanks to claudia_k !
I added a line in the httpd.conf :
XSendFile On
Now it seems to work.
But then I add something like :
XSendFileAllowAbove On
Apache will not start saying the "XSendFileAllowAbove" is not a valid param sort thing.
As noted in the XSendFile doc, the "XSendFileAllowAbove" is used for allowing download files in the parant dirs, and I thought that is the case of symfony, since the actions.class.php is in some child dirs by default.

Anyway, It works for now, and I'll leave it right there. Hope the "XSendFileAllowAbove" thing will not bring me any trouble. :?~:-?~:???:

Hello c.nicos, did you managed with XSendFileAllowAbove directive? It looks like XSendFileAllowAbove was removed a while back in favor of XSendFilePath
How did you managed?

Regards,
pisicaroz
Junior Member
 
Posts: 1
Joined: Wed Feb 26, 2014 12:30 pm
Location: Romania