mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 14:36:13 +00:00
Improve type detection
We use blob.type property to detect the content-type
This commit is contained in:
parent
bf12046afa
commit
b6d1f05e00
@ -25,8 +25,7 @@
|
||||
window.addEventListener("DOMContentLoaded", function(e) {
|
||||
var url = "{{ path('chill_main_export_generate', { 'alias' : alias } ) }}",
|
||||
query = window.location.search,
|
||||
container = document.querySelector("#download_container"),
|
||||
header_content_type
|
||||
container = document.querySelector("#download_container")
|
||||
;
|
||||
|
||||
window.fetch(url+query, { credentials: 'same-origin' })
|
||||
@ -34,14 +33,14 @@ window.addEventListener("DOMContentLoaded", function(e) {
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
}
|
||||
header_content_type = response.headers.get("Content-Type");
|
||||
|
||||
return response.blob();
|
||||
}).then(function(blob) {
|
||||
var content = URL.createObjectURL(blob),
|
||||
link = document.createElement("a"),
|
||||
suffix_file;
|
||||
|
||||
switch (header_content_type) {
|
||||
switch (blob.type) {
|
||||
case 'application/vnd.oasis.opendocument.spreadsheet':
|
||||
suffix_file = '.ods';
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user