sending headers via apache request content_type method, which seems to prevent the...
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / WWW / Vandelay.pm
index 1e80ca6..2014e70 100644 (file)
@@ -56,25 +56,26 @@ sub spool_marc {
 
        return Apache2::Const::FORBIDDEN unless verify_login($auth);
 
-
+    my $data_fingerprint = '';
        my $purpose = $cgi->param('purpose');
        my $file = $cgi->param('marc_upload');
-       my $filename = "$file";
-
-       my $data = join '', (<$file>);
-       $data = encode_base64($data);
-
-       my $data_fingerprint = md5_hex($data);
-
-       OpenSRF::Utils::Cache->new->put_cache(
-               'vandelay_import_spool_' . $data_fingerprint,
-               { purpose => $purpose, marc => $data }
-       );
-
-       print "Content-type: text/plain; charset=utf-8\n\n$data_fingerprint";
 
+    if($file and -e $file) {
+
+           my $data = join '', (<$file>);
+           $data = encode_base64($data);
+    
+           $data_fingerprint = md5_hex($data);
+    
+           OpenSRF::Utils::Cache->new->put_cache(
+                   'vandelay_import_spool_' . $data_fingerprint,
+                   { purpose => $purpose, marc => $data }
+           );
+    }
+
+    $r->content_type('text/plain; charset=utf-8');
+       print "$data_fingerprint";
        return Apache2::Const::OK;
-
 }
 
 sub verify_login {