FileServeBundle
About
The FileServeBundle allows you to serve files that are not publicly available,
such as private attachments.
Installation
Add the bundle to your composer.json:
{
"require": {
"igorw/file-serve-bundle": "1.0.*"
}
}
Add the FileServeBundle to your application's kernel:
public function registerBundles()
{
$bundles = array(
...
new Igorw\FileServeBundle\IgorwFileServeBundle(),
...
);
...
}
Usage
Use the igorw_file_serve.response_factory service to create a FileServe
response. The path is relative to the app directory by default.
$response = $this->get('igorw_file_serve.response_factory')->create('../VERSION', 'text/plain');
You can also pass a set of options as the third parameter of the create
method.
$options = array(
'serve_filename' => 'VERSION.txt',
'absolute_path' => true,
'inline' => false,
);
$response = $this->get('igorw_file_serve.response_factory')
->create('../VERSION', 'text/plain', $options);
- serve_filename: Filename the browser downloads the file as.
- absolute_path: If enabled, the bundle will ignore the
base_diroption and use the provided filename as an absolute path.
You can configure the factory used, for example to use a nginx XSendfile
response factory:
igorw_file_serve:
factory: sendfile # The default value is "php"
You can also configure the base directory:
igorw_file_serve:
base_dir: /files/dir # The default value is "%kernel.root_dir%"
Supported factories
phpsendfile(nginx)xsendfile(apache)
Features
- Incremental serving of large files
- Nginx XSendfile
- Apache mod_xsendfile
Todo
- Tests
- HTTP caching
- HTTP range requests
- Lighttpd XSendfile
- Handle PhpResponse getContent(), setContent()
Copyright (c) 2011 Igor Wiedler
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
igorw_file_serve:
factory: php
base_dir: %kernel.root_dir%
-
Use pre-installed travis composer bin
By igorw, 6 months ago
-
Add tests for all response factories
By igorw, 6 months ago
-
Add credits for inmarelibero and kbond
By igorw, 6 months ago
-
Add bugfix to CHANGELOG
By igorw, 6 months ago
-
Change test annotations to single-line format
By igorw, 6 months ago
-
Add trailing newline back to internet.txt fixture
By igorw, 6 months ago
-
Remove .idea from .gitignore
By igorw, 6 months ago
-
Merge remote-tracking branch 'kbond/patch-1'
By igorw, 6 months ago
-
added some sanity tests and travis-ci config
By kbond, 6 months ago
-
fixed typo
By kbond, 6 months ago
-
Replace readfile with stream_copy_to_stream, closes #9
By igorw, 6 months ago
-
Replace readfile with stream_copy_to_stream, closes #9
By igorw, 6 months ago
-
Replace readfile with stream_copy_to_stream, closes #9
By igorw, 6 months ago
-
Replace readfile with stream_copy_to_stream, closes #9
By igorw, 6 months ago
-
Replace readfile with stream_copy_to_stream, closes #9
By igorw, 6 months ago
-
Refactor absolute path patch, rename option to absolute_path
By igorw, 6 months ago
-
Merge remote-tracking branch 'inmarelibero/master'
By igorw, 6 months ago
-
tweaked date
By Emanuele Gaspari, 6 months ago
-
refactored code to respect original pattern
By Emanuele Gaspari, 6 months ago
-
removed unnecessary parameter binding
By Emanuele Gaspari, 6 months ago
-
Add hard dependency on symfony/http-foundation
By igorw, 7 months ago
-
Prepare 1.0.0 release
By igorw, 7 months ago
-
Switch README instructions to suggest composer installation
By igorw, 7 months ago
-
Add branch alias so that dev-master becomes 1.0.*@dev
By igorw, 7 months ago
-
Remove hard dependency on symfony/framework-bundle
By igorw, 7 months ago
-
added support for absolute filenames to serve
By inmarelibero, 7 months ago
-
Update CHANGELOG for removed request option
By igorw, 7 months ago
-
Remove request option from README
By igorw, 7 months ago
-
Fix the tests
By igorw, 7 months ago
-
Merge remote-tracking branch 'inmarelibero/master'
By igorw, 7 months ago
