hey there,
not sure if this is really true, but I expected DownloadStream#getContentDispositionFilename(String)
to encode spaces in filenames with %20
rather than +
. However, this is of course related because of using java.net.URLEncoder
as it does a application/x-www-form-urlencoded
which says: Space characters are replaced by `+’
The effect is, that at least Firefox browser suggests to download the file file with spaces.txt
with name file+with+spaces.txt
.
Unfortunately, I cannot set the Content-Disposition
parameter by hand as StreamResource#getStream()
always returns a new instance which makes
treamResource streamResource = new StreamResource(source, filename);
String cd = "attachment; " + DownloadStream.getContentDispositionFilename(filename);
streamResource.getStream().setParameter(DownloadStream.CONTENT_DISPOSITION, cd.replace("+", "%20"));
senseless.
Do you have any ideas?
Some links from my research:
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
https://vaadin.com/api/com/vaadin/server/DownloadStream.html#getContentDispositionFilename(java.lang.String)
https://vaadin.com/api/com/vaadin/server/DownloadStream.html#getContentDispositionFilename(java.lang.String)
Note: I do not have problems with this:
http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download