7 use lib "$FindBin::Bin/lib";
9 use Test::More tests => 6;
14 use File::Spec::Functions;
17 use File::Temp qw/ tempdir /;
19 my $path = catdir( getcwd(), 't', 'data', 'multipart' );
22 my $uploads = uploads_for('001');
25 $uploads->{upload2}{tempname}, qr/\.pl$/,
26 'tempname preserves .pl suffix'
30 $uploads->{upload4}{tempname}, qr/\..+$/,
31 'tempname for upload4 has no suffix'
36 my $uploads = uploads_for('006');
39 $uploads->{upload2}{tempname}, qr/\.pl$/,
40 'tempname preserves .pl suffix with Windows filename'
45 my $uploads = uploads_for('014');
48 $uploads->{upload}{tempname}, qr/\.foo\.txt$/,
49 'tempname preserves .foo.txt suffix'
53 $uploads->{upload2}{tempname}, qr/\.txt$/,
54 'tempname preserves .txt suffix when dir name has .'
58 $uploads->{upload2}{tempname}, qr/[\\\/]\w+.txt$/,
59 'tempname only gets extension from filename, not from a directory name'
66 my $headers = PAML::LoadFile( catfile( $path, "$number-headers.pml" ) );
67 my $content = IO::File->new( catfile( $path, "$number-content.dat" ) );
68 my $body = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
69 my $tempdir = tempdir( 'XXXXXXX', CLEANUP => 1, DIR => File::Spec->tmpdir() );
70 $body->tmpdir($tempdir);
72 binmode $content, ':raw';
74 while ( $content->read( my $buffer, 1024 ) ) {