Revision 31ec597c src/gr/ebs/gss/server/rest/FilesHandler.java
b/src/gr/ebs/gss/server/rest/FilesHandler.java | ||
---|---|---|
447 | 447 |
try { |
448 | 448 |
if(file != null) |
449 | 449 |
if (needsContentDisposition(req)) |
450 |
resp.setHeader("Content-Disposition","attachment; filename*=UTF-8''"+URLEncoder.encode(file.getName(),"UTF-8"));
|
|
450 |
resp.setHeader("Content-Disposition","attachment; filename*=UTF-8''"+getDispositionFilename(file));
|
|
451 | 451 |
else |
452 |
resp.setHeader("Content-Disposition","inline; filename*=UTF-8''"+URLEncoder.encode(file.getName(),"UTF-8"));
|
|
452 |
resp.setHeader("Content-Disposition","inline; filename*=UTF-8''"+getDispositionFilename(file));
|
|
453 | 453 |
if (ostream != null) |
454 | 454 |
copy(file, renderResult, ostream, req, oldBody); |
455 | 455 |
else |
... | ... | |
544 | 544 |
} |
545 | 545 |
|
546 | 546 |
/** |
547 |
* Return the filename of the specified file properly formatted for |
|
548 |
* including in the Content-Disposition header. |
|
549 |
*/ |
|
550 |
private String getDispositionFilename(FileHeaderDTO file) throws UnsupportedEncodingException { |
|
551 |
return URLEncoder.encode(file.getName(),"UTF-8").replaceAll("\\+", "%20"); |
|
552 |
} |
|
553 |
|
|
554 |
/** |
|
547 | 555 |
* Determines whether the user agent needs the Content-Disposition |
548 | 556 |
* header to be set, in order to properly download a file. |
549 | 557 |
* |
Also available in: Unified diff