NAME
Mojolicious::Plugin::RenderFile - "render_file" helper for Mojolicious
SYNOPSIS
# Mojolicious
$self->plugin('RenderFile');
# Mojolicious::Lite
plugin 'RenderFile';
# In controller
$self->render_file('filepath' => '/tmp/files/file.pdf'); # file name will be "file.pdf"
# Provide any file name
$self->render_file('filepath' => '/tmp/files/file.pdf', 'filename' => 'report.pdf');
# Open file in browser(do not show save dialog)
$self->render_file(
'filepath' => '/tmp/files/file.pdf',
'content_type' => 'application/pdf', # default 'application/x-download'
'content_disposition' => 'inline', # default 'attachment'
);
DESCRIPTION
Mojolicious::Plugin::RenderFile is a Mojolicious plugin that adds "render_file" helper. It does not read file in memory and just streaming it to client.
HELPERS
render_file
$self->render_file(filepath => '/tmp/files/file.pdf', 'filename' => 'report.pdf' );
With this helper you can easily provide files for download. By default "content_type" is "application/x-download" and "content_disposition" is "attachment". Therefore, a browser will ask where to save file.
This plugin respects HTTP Range headers.
Register plugin in Mojolicious application.
AUTHOR
Viktor Turskyi <koorchik@cpan.org>
CONTRIBUTORS
Nils Diewald (Akron)
BUGS
Please report any bugs or feature requests to Github https://github.com/koorchik/Mojolicious-Plugin-RenderFile