Rex-Repositorio
view release on metacpan or search on metacpan
lib/Rex/Repositorio/Server/Helper/RenderFile.pm view on Meta::CPAN
# Open file in browser(do not show save dialog)
$self->render_file(
'filepath' => '/tmp/files/file.pdf',
'format' => 'pdf', # will change Content-Type "application/x-download" to "application/pdf"
'content_disposition' => 'inline', # will change Content-Disposition from "attachment" to "inline"
'cleanup' => 1, # delete file after completed
);
=head1 DESCRIPTION
L<Mojolicious::Plugin::RenderFile> is a L<Mojolicious> plugin that adds "render_file" helper. It does not read file in memory and just streaming it to a client.
=head1 HELPERS
=head2 C<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" header is "application/x-download" and "content_disposition" option value is "attachment".
Therefore, a browser will ask where to save file. You can provide "format" option to change "Content-Type" header.
( run in 0.220 second using v1.01-cache-2.11-cpan-4d50c553e7e )