From b6d1f05e00bdf71ccdc64e9935744c1bfb1a16ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2017 14:24:34 +0200 Subject: [PATCH] Improve type detection We use blob.type property to detect the content-type --- Resources/views/Export/download.html.twig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Resources/views/Export/download.html.twig b/Resources/views/Export/download.html.twig index c517c37e8..d1f670d74 100644 --- a/Resources/views/Export/download.html.twig +++ b/Resources/views/Export/download.html.twig @@ -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;