x-sendfile

rails media file stream accept byte range request through send_data or send_file method

时光怂恿深爱的人放手 提交于 2019-11-26 11:07:56
问题 I have the following problem. Sounds are hidden from the public folder, cause there are only certain Users who should have access to the sound files. So I made a certain method, which acts like a sound url, but calculates first, whether the current user is allowed to access this file. The file gets sent by the send_data method. The problem is just, that I it works quite slow if it works even... The developer of the jplayer plugin, which I use to play the sound, told me that I should be able

Using X-Sendfile with Apache/PHP

大城市里の小女人 提交于 2019-11-26 04:49:15
问题 I can\'t seem to find much documentation on X-Sendfile or example code for PHP (there is some rails code). Anyone used it before and would mind giving a quick snippet of code and a brief description? 回答1: X-Sendfile is an HTTP header, so you want something like this: header("X-Sendfile: $filename"); Your web server picks it up if correctly configured. Here's some more details: http://www.jasny.net/articles/how-i-php-x-sendfile/ 回答2: If tweaking the web server configuration is not an option,

Fastest Way to Serve a File Using PHP

走远了吗. 提交于 2019-11-26 04:03:56
问题 I\'m trying to put together a function that receives a file path, identifies what it is, sets the appropriate headers, and serves it just like Apache would. The reason I am doing this is because I need to use PHP to process some information about the request before serving the file. Speed is critical virtual() isn\'t an option Must work in a shared hosting environment where the user has no control of the web server (Apache/nginx, etc) Here\'s what I\'ve got so far: File::output($path); <?php