Changing default behavior of upload handling to stop taking over the upload extension...
[catagits/HTTP-Body.git] / lib / HTTP / Body / MultiPart.pm
index c9273d4..18354ab 100644 (file)
@@ -256,7 +256,9 @@ sub parse_body {
 =cut
 
 our $basename_regexp = qr/[^.]+(\.[^\\\/]+)$/;
-#our $basename_regexp = qr/(\.\w+(?:\.\w+)*)$/;
+our $file_temp_suffix = '.upload';
+our $file_temp_template;
+our %file_temp_parameters;
 
 sub handler {
     my ( $self, $part ) = @_;
@@ -277,7 +279,11 @@ sub handler {
                 my $basename = (File::Spec->splitpath($filename))[2];
                 my $suffix = $basename =~ $basename_regexp ? $1 : q{};
 
-                my $fh = File::Temp->new( UNLINK => 0, DIR => $self->tmpdir, SUFFIX => $suffix );
+                my $fh = File::Temp->new(
+                    UNLINK => 0, DIR => $self->tmpdir, SUFFIX => ($file_temp_suffix||$suffix),
+                    ( $file_temp_template ? ( TEMPLATE => $file_temp_template ) : () ),
+                    %file_temp_parameters,
+                );
 
                 $part->{fh}       = $fh;
                 $part->{tempname} = $fh->filename;
@@ -311,6 +317,10 @@ sub handler {
 
 =back
 
+=head1 SUPPORT
+
+See L<HTTP::Body>
+
 =head1 AUTHOR
 
 Christian Hansen, C<ch@ngmedia.com>