From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 46AF991121; Wed, 7 Sep 2022 10:58:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 586472F8D2; Wed, 7 Sep 2022 10:58:35 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS; Wed, 7 Sep 2022 10:58:32 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B66D543F49; Wed, 7 Sep 2022 10:58:31 +0200 (CEST) From: Daniel Tschlatscher To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com, pmg-devel@lists.proxmox.com Date: Wed, 7 Sep 2022 10:56:32 +0200 Message-Id: <20220907085633.89113-7-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220907085633.89113-1-d.tschlatscher@proxmox.com> References: <20220907085633.89113-1-d.tschlatscher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.075 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH widget-toolkit v2 6/7] Source file download call in central function X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Sep 2022 08:58:38 -0000 Adds a function for downloading a file from a remote URL in the Utils class and uses it to revise one similar usage in FileBrowser.js Signed-off-by: Daniel Tschlatscher --- src/Utils.js | 13 +++++++++++++ src/window/FileBrowser.js | 11 +++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index 6a03057..bb68937 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -1272,6 +1272,19 @@ utilities: { .map(val => val.charCodeAt(0)), ); }, + + // Setting filename here when downloading from a remote url sometimes fails in chromium browsers + // because of a bug when using attribute download in conjunction with a self signed certificate. + // For more info see https://bugs.chromium.org/p/chromium/issues/detail?id=993362 + downloadAsFile: function(source, fileName) { + let hiddenElement = document.createElement('a'); + hiddenElement.href = source; + hiddenElement.target = '_blank'; + if (fileName) { + hiddenElement.download = fileName; + } + hiddenElement.click(); + }, }, singleton: true, diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index a519d6b..4e4c639 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -101,18 +101,17 @@ Ext.define("Proxmox.window.FileBrowser", { let params = { ...view.extraParams }; params.filepath = data.filepath; - let atag = document.createElement('a'); - atag.download = view.downloadPrefix + data.text; + let filename = view.downloadPrefix + data.text; if (data.type === 'd') { if (tar) { params.tar = 1; - atag.download += ".tar.zst"; + filename += ".tar.zst"; } else { - atag.download += ".zip"; + filename += ".zip"; } } - atag.href = me.buildUrl(view.downloadURL, params); - atag.click(); + + Proxmox.Utils.downloadAsFile(me.buildUrl(view.downloadURL, params), filename); }, fileChanged: function() { -- 2.30.2