Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 736b3327

Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)

Re #8706 - Bugfix of downloading identity binary files

Zobrazit rozdíly:

static/js/utilities.js
19 19
    document.body.removeChild(element);
20 20
}
21 21

  
22
/**
23
 * Generate a file to be downloaded by the browser as a binary file
24
 * @param filename name of the file to be downloaded
25
 * @param data content of the downloaded file
26
 */
27
function downloadBinary(filename, data) {
28
    var blob = new Blob([data], {type: "application/x-pkcs12"});
29
    saveAs(blob, filename);
30
}
31

  
22 32
// Adds toDateInputValue() method to Date object
23 33
// toDateInputValue() produces date in YYYY-MM-DD format
24 34
Date.prototype.toDateInputValue = (function () {
......
119 129
            name: name,
120 130
            password: passphrase
121 131
        }
122
        const response = await axios.post(API_URL + "certificates/" + id + "/identity", identityData);
123
        download(name + ".p12", response.data)
132
        const response = await axios.post(API_URL + "certificates/" + id + "/identity", identityData, {
133
            responseType: "arraybuffer",
134
            headers: {
135
                'Content-Type': 'application/json',
136
                'Accept': 'application/x-pkcs12 '
137
            }
138
        });
139
        downloadBinary(name + ".p12", response.data)
124 140
    } catch (error) {
125 141
        console.log(error);
126 142
    }

Také k dispozici: Unified diff