Bug 7775 - tools/upload-file.pl: scoping for plack

$uploaded_file is now scoped with our, and we set correct filename

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Dobrica Pavlinusic 2012-03-21 11:47:49 +01:00 committed by Paul Poulain
parent d4233cf1dd
commit db312526b2
1 changed files with 2 additions and 5 deletions

View File

@ -46,7 +46,7 @@ if ($auth_status ne "ok") {
exit 0;
}
my $uploaded_file = C4::UploadedFile->new($sessionID);
our $uploaded_file = C4::UploadedFile->new($sessionID);
unless (defined $uploaded_file) {
# FIXME - failed to create file for some reason
send_reply('failed', '');
@ -54,8 +54,6 @@ unless (defined $uploaded_file) {
}
$uploaded_file->max_size($ENV{'CONTENT_LENGTH'}); # may not be the file size, exactly
my $first_chunk = 1;
my $query;
$query = new CGI \&upload_hook;
$uploaded_file->done();
@ -68,9 +66,8 @@ exit 0;
sub upload_hook {
my ($file_name, $buffer, $bytes_read, $session) = @_;
$uploaded_file->stash(\$buffer, $bytes_read);
if ($first_chunk) {
if ( ! $uploaded_file->name && $file_name ) { # save name on first chunk
$uploaded_file->name($file_name);
$first_chunk = 0;
}
}