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 in iOS

timomeinen opened this issue · comments

Using DynamicFileDownloader does not work with mobile version of Safari in iOS. Instead of downlading the file with the given filename, Safari adds a ".html" to the original filename and stores any data as text file.

Example trying to download a .pdf file:
Bildschirmfoto 2024-03-05 um 09 06 42

Other than other browsers, mobile Safari does not take the file ending as a guess for the mime type, instead it expects a http Content-Type header.

I want to recommend adding Content-Type header to every response. RFC2046 defines mime type application/octet-stream as an "arbitrary binary data" which could be used as a default value for unknown binary data. Browsers will use file ending to determine it in this case.

As the download button will most likely be used in the context of web browsers, I think it is safe to always provide a Content-Type.

Adding the Content-Type (no matter octet-stream or real mime type) will allow correct file download handling in mobile Safari.

Please find attached a pull request.

More resources: