]> git.proxmox.com Git - pmg-gui.git/commitdiff
SpamQuarantine: fix download of large emails
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 23 Oct 2019 07:36:35 +0000 (09:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 25 Oct 2019 07:19:05 +0000 (09:19 +0200)
since datauri downloads are size limited (2MB in chrome), we have
to use another method, and instead of working around in the gui
(e.g. by using URL.createObjectURL) make use of the existing download
code in the api, which should have better compatibility
(and omits the whole raw -> json -> raw -> base64 conversion chain from
file to download)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
js/SpamQuarantine.js

index 7141ecc1dace90096c94530ab89904a85d4df754..d1b32f045ab12e7455910b3bc48dd32b6c71c559 100644 (file)
@@ -164,39 +164,22 @@ Ext.define('PMG.SpamQuarantine', {
                return; // multi download is not implemented
            }
            var rec = selection[0];
-           var url = '/api2/extjs/quarantine/content';
-           Proxmox.Utils.API2Request({
-               url: url,
-               params: {
-                   id: rec.data.id,
-                   raw: 1
-               },
-               method: 'GET',
-               failure: function(response, opts) {
-                   Ext.Msg.alert('Error', response.htmlStatus);
-               },
-               success: function(response, opts) {
-                   var data = response.result.data;
-                   var raw = data.header;
-                   raw += '\n';
-                   raw += data.content;
-
-                   var link = Ext.DomHelper.append(document.body, {
-                       tag: 'a',
-                       href: 'data:message/rfc822,' + encodeURIComponent(raw),
-                       css: 'display:none;visibility:hidden;height: 0px;',
-                       download: rec.data.id + '.eml'
-                   });
-
-                   if (link.fireEvent) {
-                       link.fireEvent('onclick');
-                   } else {
-                       var evt = document.createEvent("MouseEvents");
-                       evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
-                       link.dispatchEvent(evt);
-                   }
-               }
+           var url = "/api2/json/quarantine/download?mailid=" +
+                       encodeURIComponent(rec.data.id);
+           var link = Ext.DomHelper.append(document.body, {
+               tag: 'a',
+               href: url,
+               css: 'display:none;visibility:hidden;height: 0px;',
+               download: rec.data.id + '.eml'
            });
+
+           if (link.fireEvent) {
+               link.fireEvent('onclick');
+           } else {
+               var evt = document.createEvent("MouseEvents");
+               evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
+               link.dispatchEvent(evt);
+           }
        },
 
        openContextMenu: function(table, record, tr, index, event) {