4 ms·
data uris do not support setting something equivalent to http’s disposition header, which is what prompted the addition of the download html attribute. data uri
by ZenPsycho 8y ago
data uris do not support setting something equivalent to http’s disposition header, which is what prompted the addition of the download html attribute. data uris also do not permit setting a sensible filename, the other feature the download attribute patches over. safari supports neither, and mobile safari is also in general incapable of sensibly dealing with an anonymous blob like that. (what could it even actually do? what app would you open it with? what would it be named?)
- zawerf 8y agoUh you can definitely set the mime type in data uris. It's like right there as the first part of a data uri... Download attribute let's you choose a filename. But giving up on that for safari sounds like a decent tradeoff to me (with the current approach you end up with a nonsense png extension in the save file anyway). Testing with a quick demo: https://codepen.io/anon/pen/wYpBry?editors=1010 https://codepen.io/anon/pen/wYpBry?editors=1010, it seems like mobile safari will show it as unknown.txt but have options to save to files/dropbox etc. Kind of complicated but probably still less confusing than a png file.
- ikromin 8y agoThe download attribute is not supported on mobile Safari unfortunately - https://caniuse.com/download/embed/description https://caniuse.com/download/embed/description
- murkle 8y agohttps://codepen.io/anon/pen/wYpBry?editors=1010 https://codepen.io/anon/pen/wYpBry?editors=1010 is very cool, thanks!
- ZenPsycho 8y agoI didn't say anything about mime type. I said disposition (which is what you would use to force a file to download, instead of display in browser, using the http protocol), and filename. If you set mimetype to octet, mobile safari, since it does not support the download attribute, cannot name it anything sensible or choose an appropriate file extension. I always felt like data: urls could obtain a lot more utility if disposition and filename attributes were added to it, but... uhm, browser makers don't seem to agree, and the syntax would make it difficult to add features like that whilst staying backwards compatible.