[pve-devel] [PATCH RESEND http-server 06/10] allow 'download' to be passed from API handler
Stefan Reiter
s.reiter at proxmox.com
Wed Apr 21 13:15:35 CEST 2021
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 at proxmox.com>
---
PVE/APIServer/AnyEvent.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
index 8a1af54..60a2a1c 100644
--- a/PVE/APIServer/AnyEvent.pm
+++ b/PVE/APIServer/AnyEvent.pm
@@ -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;
}
--
2.20.1
More information about the pve-devel
mailing list