0
I need to catch "Content-Disposition" header on https Response .. about a file download, but it fails. I’m using Spring (Security) REST with HTTPS. My frontend is made with Jquery. I appreciate any help. I’m Working by 2 days and .. Nothing!
Important: when i observe on browser network console .. the headers on https Datagram is ok. Content-Disposition is there. And the file (a image) already Arrived from backend. it Sounds Strange ...
$.ajax({
url: backend+"/noauthe/filemngr/Download",
type: "POST",
cache: false,
headers: { 'Content-Type':'image/jpeg' },
responseType:'arraybuffer',
timeout: 2000,
data: JSON.stringify(fileDescriptor)
}).success(function(data, textStatus, jqXHR) {
var downloadBlob = document.createElement("a");
downloadBlob.href = URL.createObjectURL(new Blob([data], {type: jqXHR.getResponseHeader("Content-Type")}));
downloadBlob.download = jqXHR.getResponseHeader("Content-Disposition").split("=")[1].trim();
document.body.appendChild(downloadBlob);
downloadBlob.click();
document.body.removeChild(downloadBlob);
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log('[ERROR]');
console.log(jqXHR);
});
can anybody help me?! Thanks ...
When a Try catch Content-Disposition on Response .. it is null. I need catch filename on this header.
– Julio Gustavo Costa
Could you translate your question? You are in the English version of Stack Overflow.
– Renan Gomes
Iiiiii ehehheh, okay. So, I need to access the 'Content-Disposition' in HTTPS responses in order to have the file name (set in this header) for download in browser. I am using Jquery on the frontend and Spring (Security and REST) on the backend. All requests are made on HTTPS. The moment I try to capture 'Content-Disposition' it comes as null. However, if you look at the browser debugging console, the network tab, the headers are all there and the image (the downloadable file) is there. It’s weird.
– Julio Gustavo Costa
the timout parameter in the options of the call ajax put to test on the last try, and nothing. already test with and without it ..
– Julio Gustavo Costa
@Juliogustavocosta you must [Dit] the question to translate, then it can be reopened.
– Maniero