Viritin-2.5 DownloadButton – setMimeType() has no effect

Hello everyone :slight_smile:

This is my first post on the forum. Let me begin by saying that it’s a real pleasure for me to work with Framework 8 and Viritin – thanks to everyone involved!

Now, to the issue at hand. My application backend generates a Report as an OutputStream with JasperReports. This happens in my implementation of DownloadButton.ContentWriter, so the stream in public void write(OutputStream stream) { gets filled with the report. Then I create a DownloadButton:

DownloadButton pdfButton = new DownloadButton();
		
//[...]

pdfButton.setWriter(new MyContentWriter(bean, InitVars.REPORT_FORMAT_PDF));
pdfButton.setCacheTime(1L);
pdfButton.setFileNameProvider(new MyReportFileNameProvider(bean, InitVars.REPORT_FORMAT_PDF));

MimeTypeProvider test = new MimeTypeProvider() {
	@Override
	public String getMimeType() {
		return "application/pdf";
	}
};
pdfButton.setMimeTypeProvider(test);
//I tried this line before the MimeTypeProvider:
//pdfButton.setMimeType(MediaType.PDF.toString()); //gives "application/pdf" as well
//Has the same "effect"
MyView.LOG.debug("MimeType when building the view: " + pdfButton.getMimeType());

Now, when the view with this component is built, the log says “application/pdf” as expected. The download also works flawlessly, giving me a pdf-file that I can open. However, in the browser (I have Firefox 59.0.1), the download-dialog-box displays it as Type Unknown, unlike a normal pdf download. Same for a second button with xlsButton.setMimeType("application/vnd.ms-excel"); – and I’d really like it if it recognised the MimeTypes :slight_smile:

My first thought was that the MimeType is perhaps overwritten in the ContentWriter so I gave the button as parameter to my ContentWriter and had it log the button.getMimeType() after the Report was written to the OutputStream. There the log also gives “application/pdf”. So that’s not it.

Thus I’m at a loss – it seems like I do everything like the various examples on the web demonstrate, yet my MimeTypes are not recognised by Firefox. Any ideas? Any additional information I should provide?

Thanks in advance for your views.

Well, what to say :smiley: Apparently it’s a browser bug. When I connect to the localhost server from another box in the network the mime-type works just fine.