Reputation: 35
Trying to download a file from AWS S3 using presigned Url , and i set the file name in Content Desposition. The file name is having comma " , " . while i tried downloading this file using that presigned URL, got this error in Browser ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION. Here is my java code.
ResponseHeaderOverrides override = new ResponseHeaderOverrides();
override.setContentDisposition("attachment; filename="+ "BM, EN-POP, SWP - 8P GUK A.pptx");
GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(Bucket_name,S3_Object)
.withMethod(HttpMethod.GET)
.withExpiration(expiration)
.withResponseHeaders(override);`
the Generated presigned URl is:
Anyone having any idea, the comma in the filename mentioned in content-Desposition can not be replaced.
Upvotes: 1
Views: 2281
Reputation: 21
Recommended syntax for the Content-Disposition
header is to surround the filename with quotes.
Content-Disposition: inline
Content-Disposition: attachment
Content-Disposition: attachment; filename="filename.jpg"
Content-Disposition: attachment; filename*="filename.jpg"
The quotes around the filename are optional, but are necessary if you use special characters in the filename, such as spaces.
Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#syntax
Upvotes: 1