viritin / flow-viritin

Viritin inspired project for Vaadin Flow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Download not working on mobile Safari anymore

timomeinen opened this issue · comments

Hi @mstahv,

in #45 I have raised a PR to add the Content-Type header in order to allow downloads on mobile safari iOS. Unfortunately, setting the header had been removed in commit e52f658 in this line for issue #49. I assume it was tested on macOS desktop Safari. The behaviour is different between mobile and desktop Safari. If Content-Type header is missing, mobile Safari will not honor file extension and instead adds a .html to the download filename making it impossible to download a e.g. PDF. In contrast, if header is missing on desktop Safari, the browser guesses mime type by file extension.

Please re-add the header again to enable downloads on mobile safari:

response.setHeader("Content-Type", contentTypeGenerator.getContentType());

Note: The @FunctionInterface ContentTypeGenerator still exists in the code, but the method getContentType is never called. This was hard to find, as my program continued to set the withContentTypeGenerator but the lambda itself was not called anymore.

Please see attached PR.

Thanks,
Timo

Thanks Timo, dropped it by accident when copy pasting another fix! 2.8.15 on its way to central.

Should start writing some tests for this and the upload component, second regression in short time 😬