-
-
24 Sep 2017 08:47:42 UTC
- Distribution: Mojolicious-Plugin-RenderFile
- Module version: 0.12
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (1747 / 0 / 29)
- Kwalitee
Bus factor: 0- 84.44% Coverage
- License: unknown
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (4.81KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Mojolicious
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
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'); # Render data from memory as file $self->render_file('data' => 'some data here', 'filename' => 'report.pdf'); # 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 );
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 a 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" 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.
Supported Options:
filepath
-
Path on the filesystem to the file. You must always pass "filepath" or "data" option
data
-
Binary content which will be transferred to browser. You must always pass "filepath" or "data" option
filename
(optional)-
Browser will use this name for saving the file
format
(optional)-
The "Content-Type" header is based on the MIME type mapping of the "format" option value. These mappings can be easily extended or changed with "types" in Mojolicious.
By default "Content-Type" header is "application/x-download"
content_disposition
(optional)-
Tells browser how to present the file.
"attachment" (default) - is for dowloading
"inline" - is for showing file inline
cleanup
(optional)-
Indicates if the file should be deleted when rendering is complete
This plugin respects HTTP Range headers.
AUTHOR
Viktor Turskyi <koorchik@cpan.org>
CONTRIBUTORS
Nils Diewald (Akron) Danil Greben (SDSWanderer)
BUGS
Please report any bugs or feature requests to Github https://github.com/koorchik/Mojolicious-Plugin-RenderFile
SEE ALSO
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
Copyright 2011 Viktor Turskyi
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Module Install Instructions
To install Mojolicious::Plugin::RenderFile, copy and paste the appropriate command in to your terminal.
cpanm Mojolicious::Plugin::RenderFile
perl -MCPAN -e shell install Mojolicious::Plugin::RenderFile
For more information on module installation, please visit the detailed CPAN module installation guide.