in reply to Download big file in chunks with plack response

Updated in the end
  • Comment on Re: Download big file in chunks with plack response

Replies are listed 'Best First'.
Re^2: Download big file in chunks with plack response
by Anonymous Monk on Apr 26, 2021 at 08:29 UTC

    here is the final code:

    Correction ;)

    my $app = sub { use Path::Tiny qw/ path /; use File::MimeInfo qw/ mimetype /; my $env = shift; my $path_file = 'win.iso'; my $content_type = mimetype($path_file) || 'application/octet-stre +am'; my $basename = path($path_file)->basename; $basename =~ s{[^\w\.-]+}{_}g; my $filehandle = path($path_file)->openr_raw ; return [ 200, [ 'Content-Type' => $content_type, 'Content-Length' => -s $filehandle, 'Content-Disposition' => qq[attachment; filename="$basenam +e"], ], $filehandle ]; };