Catalyst-Plugin-Static-File
view release on metacpan or search on metacpan
In your Catalyst class:
```perl
use Catalyst qw/
Static::File
/;
```
In a controller method:
```
$c->serve_static_file( $absolute_path, $type );
```
# DESCRIPTION
This plugin provides a simple method for your [Catalyst](https://metacpan.org/pod/Catalyst) app to send a specific static file.
Unlike [Catalyst::Plugin::Static::Simple](https://metacpan.org/pod/Catalyst%3A%3APlugin%3A%3AStatic%3A%3ASimple),
- It only supports serving a single file, not a directory of static files. Use [Plack::Middleware::Static](https://metacpan.org/pod/Plack%3A%3AMiddleware%3A%3AStatic) if you want to
serve multiple files.
- It assumes that you know what you're doing. If the file does not exist, it will throw an fatal error.
- It uses [Plack::MIME](https://metacpan.org/pod/Plack%3A%3AMIME) to identify the content type, but you can override that.
- It adds a file path to the file handle, and plays nicely with [Plack::Middleware::XSendfile](https://metacpan.org/pod/Plack%3A%3AMiddleware%3A%3AXSendfile) and [Plack::Middleware::ETag](https://metacpan.org/pod/Plack%3A%3AMiddleware%3A%3AETag).
- It does not log anything.
# RECENT CHANGES
Changes for version v0.2.5 (2026-07-17)
- Documentation
- README is now generated by Dist::Zilla::Plugin::UsefulReadme.
- Removed separate INSTALL file.
- Adjusted wording for consistency.
- Updated the copyright year.
- Updated maintainer email.
- Fixed the git repo URL in SOURCE.
- Added doap.xml to the distribution.
- Tests
- Skip Plack::Middleware::XSendfile test if it is no installed.
- Moved author tests into the xt directory.
- Added more author tests.
- Toolchain
- Improved Dist::Zilla configuration.
- Sign distribution with SigStore instead of Module::Signature.
See the `Changes` file for more details.
# REQUIREMENTS
This module lists the following modules as runtime dependencies:
- [Catalyst](https://metacpan.org/pod/Catalyst) version 5.90129 or later
- [File::Spec](https://metacpan.org/pod/File%3A%3ASpec)
- [File::stat](https://metacpan.org/pod/File%3A%3Astat)
- [IO::File](https://metacpan.org/pod/IO%3A%3AFile)
- [Moose::Role](https://metacpan.org/pod/Moose%3A%3ARole)
- [Plack::MIME](https://metacpan.org/pod/Plack%3A%3AMIME)
- [Plack::Util](https://metacpan.org/pod/Plack%3A%3AUtil)
- [Try::Tiny](https://metacpan.org/pod/Try%3A%3ATiny)
- [namespace::autoclean](https://metacpan.org/pod/namespace%3A%3Aautoclean)
- [perl](https://metacpan.org/pod/perl) version v5.14.0 or later
See the `cpanfile` file for the full list of prerequisites.
# INSTALLATION
The latest version of this module (along with any dependencies) can be installed from [CPAN](https://www.cpan.org) with the `cpan` tool that is included with Perl:
```
cpan Catalyst::Plugin::Static::File
```
You can also extract the distribution archive and install this module (along with any dependencies):
```
cpan .
```
You can also install this module manually using the following commands:
```
perl Makefile.PL
make
make test
make install
```
If you are working with the source repository, then it may not have a `Makefile.PL` file. But you can use the [Dist::Zilla](https://dzil.org/) tool in anger to build and install this module:
```
dzil build
dzil test
dzil install --install-command="cpan ."
```
For more information, see [How to install CPAN modules](https://www.cpan.org/modules/INSTALL.html).
# SECURITY CONSIDERATIONS
The [serve\_static\_file](https://metacpan.org/pod/serve_static_file) method does not validate the file that is passed to it.
You should ensure that arbitrary filenames are not passed to it. You should strictly validate any external data that is
used for generating the filename.
# SUPPORT
Only the latest version of this module will be supported.
This module requires Perl v5.14 or later. Future releases may only support Perl versions released in the last ten
years.
This module requires Catalyst v5.90129 or later.
## Reporting Bugs and Submitting Feature Requests
Please report any bugs or feature requests on the bugtracker website
[https://github.com/robrwo/Catalyst-Plugin-Static-File/issues](https://github.com/robrwo/Catalyst-Plugin-Static-File/issues)
When submitting a bug or request, please include a test-file or a
( run in 1.127 second using v1.01-cache-2.11-cpan-5fbc6bb55f2 )