WebApp::Helpers::MimeTypes - simple role for MIME::Types support
package MyTunes::Resource::CD;
use Moo;
with 'WebApp::Helpers::MimeTypes';
sub to_excel {
my ($self) = @_;
my ($filehandle) = $self->make_temp_file();
return [
200, ['Content-Type' => $self->mime_type_for('xlsx')],
[ $filehandle ],
];
}
WebApp::Helpers::MimeTypes is a simple role that holds a
MIME::Types object and provides some sugar methods. I
work a lot with Microsoft Excel 2007 files, and I hate trying to
remember their mime-type
(application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
).
A MIME::Types object.
Returns the MIME type for a file with the given $extension
e.g.
mime_type_for('csv')
returns 'text/comma-separated-values'
.
Copyright (C) Fitz Elliott.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Fitz Elliott felliott@fiskur.org