I'm trying to make a file upload/downloader with Mojolicious::Lite and while the upload section is no problem the download section is causing trouble. This code will let me download small text files but anything else turns into a 0 byte file. Any advice on how to do this right?
get '/download/:file' => sub {
my $self = shift;
my $file = $self->param('file');
$self->res->headers->content_type("application/x-download");
$self->res->content->asset(Mojo::Asset::File->new(path => "./testdir/$file"));
$self->rendered;
};
Joel Berger posted this little program to start a web server to serve local files, and it works great: