DownloadStream wrongly encodes filename?

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 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"));


Do you have any ideas?

Some links from my research:

Note: I do not have problems with this:

The only way I found to cope with that issue is to override the
method and in there to call my own
-method instead of the original method of class DownloadStream.

The method looks as follows:

public String getContentDispositionFilename() { String filename = onDemandStreamResource.getFilename(); String filenameNoBlanks = filename.replace(" ", "%20"); // replace blanks with %20 for firefox, chrome and ie don't need that return String.format("filename=\"%s\"; filename*=utf-8\'\'%s", new Object[]{filename, filenameNoBlanks}); }

Instead of url encoding the filename as done in the original method here only blanks are replaced by “%20” for the “filename*=utf-8”-part. In chrome and IE it seems to work well even with blanks, however, Firefox can not read the filename if it contains blanks.