App-BlurFill
view release on metacpan or search on metacpan
lib/App/BlurFill/Web.pm view on Meta::CPAN
get '/download/:filename' => sub {
my $filename = route_parameters->get('filename');
# Security: only allow filenames without path traversal
return status 400, { error => 'Invalid filename' }
if $filename =~ m{[/\\]};
my $filepath = File::Spec->catfile($TEMP_DIR, $filename);
return status 404, { error => 'File not found' }
unless -f $filepath;
# Determine content type from extension
my $ext = lc($filename);
$ext =~ s/.*\.//;
my %mime = (
jpg => 'image/jpeg',
jpeg => 'image/jpeg',
png => 'image/png',
};
# Test GET /download/:filename route
# Note: This test assumes a file exists in the temp directory from the previous POST test
# In practice, we'd need to ensure a file exists, but for this test we'll just verify the route exists
test_psgi
app => $app,
client => sub {
my $cb = shift;
my $res = $cb->(GET '/download/nonexistent_file.jpg');
is($res->code, 404, 'Got 404 for non-existent file');
};
done_testing;
( run in 1.937 second using v1.01-cache-2.11-cpan-39bf76dae61 )