note
Thenothing
Hello there kikuchiyo <br>
A big thank you for you testing, now the code is working
<br><br>
The problem was, I was using plackup -L Shotgun to run the psgi app, and the error I was getting was. <br><br>
Magic number checking on storable string failed at /usr/lib/x86_64-linux-gnu/perl/5.22/Storable.pm line 420, at /usr/local/share/perl/5.22.1/Plack/Loader/Shotgun.pm line 35. Sometimes I get the error memory<br> <br>
But when I change to just plackup, everything works <br>
here is the final code:<br><br>
<code>
use strict;
use warnings;
####use Plack::Response; # doesn't seem to support streaming response
use Path::Tiny;
use File::MimeInfo;
my $app = sub {
my $env = shift;
my $path_file = 'win.iso';
my $content_type = mimetype($path_file);
$content_type = 'application/octet-stream' if not defined $content_type;
require File::Spec::Unix;
my $basename = $path_file;
$basename =~ s|\\|/|g;
$basename = ( File::Spec::Unix->splitpath($basename) )[2];
$basename =~ s|[^\w\.-]+|_|g;
return sub {
my $responder = shift;
my $writer = $responder->(
[ 200, [
'Content-Type' => $content_type,
'Content-Disposition' => qq[attachment; filename="$basename"],
]
]
);
open (FILE, "< $path_file") or die "can't open $path_file: $!";
binmode FILE;
local $/ = \102400;
while (<FILE>) {
$writer->write($_);
}
$writer->close();
close FILE;
}
}
</code>
again thank you so much for your time and your code
11131529
11131686