mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46: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) {
|
window.addEventListener("DOMContentLoaded", function(e) {
|
||||||
var url = "{{ path('chill_main_export_generate', { 'alias' : alias } ) }}",
|
var url = "{{ path('chill_main_export_generate', { 'alias' : alias } ) }}",
|
||||||
query = window.location.search,
|
query = window.location.search,
|
||||||
container = document.querySelector("#download_container"),
|
container = document.querySelector("#download_container")
|
||||||
header_content_type
|
|
||||||
;
|
;
|
||||||
|
|
||||||
window.fetch(url+query, { credentials: 'same-origin' })
|
window.fetch(url+query, { credentials: 'same-origin' })
|
||||||
@ -34,14 +33,14 @@ window.addEventListener("DOMContentLoaded", function(e) {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw Error(response.statusText);
|
throw Error(response.statusText);
|
||||||
}
|
}
|
||||||
header_content_type = response.headers.get("Content-Type");
|
|
||||||
return response.blob();
|
return response.blob();
|
||||||
}).then(function(blob) {
|
}).then(function(blob) {
|
||||||
var content = URL.createObjectURL(blob),
|
var content = URL.createObjectURL(blob),
|
||||||
link = document.createElement("a"),
|
link = document.createElement("a"),
|
||||||
suffix_file;
|
suffix_file;
|
||||||
|
|
||||||
switch (header_content_type) {
|
switch (blob.type) {
|
||||||
case 'application/vnd.oasis.opendocument.spreadsheet':
|
case 'application/vnd.oasis.opendocument.spreadsheet':
|
||||||
suffix_file = '.ods';
|
suffix_file = '.ods';
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user