]> git.proxmox.com Git - pve-http-server.git/commitdiff
allow 'download' to be passed from API handler
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 21 Apr 2021 11:15:35 +0000 (13:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Apr 2021 15:42:01 +0000 (17:42 +0200)
PVE::HTTPServer in pve-manager wraps the API return value in a 'data'
element, look for a 'download' element there too to allow an API call to
instruct the HTTP server to return a file via path or filehandle.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/APIServer/AnyEvent.pm

index 8a1af54bf8e2851c7a4812b033cc52d3f0709c4b..60a2a1c5f64628acd0cb1ea6beadc07cc565de18 100644 (file)
@@ -812,7 +812,10 @@ sub handle_api2_request {
            $delay = 0 if $delay < 0;
        }
 
-       if (defined(my $download = $res->{download})) {
+       my $download = $res->{download};
+       $download //= $res->{data}->{download}
+            if defined($res->{data}) && ref($res->{data}) eq 'HASH';
+       if (defined($download)) {
            send_file_start($self, $reqstate, $download);
            return;
        }