Update
This error has been fixed since version 1.4.1.0 of the SDK.
Bypass
This is a confirmed bug in the AWS SDK , so until they release a fix, I am going to crack this one to get everything working:
Specify the type of content as you want it to appear in the response header. So, if you want S3 to return the image/svg+xml content type, set it exactly like this:
ResponseHeaderOverrides headerOverrides = new ResponseHeaderOverrides(); headerOverrides.ContentType = "image/svg+xml";
Now, go ahead and generate a pre-signed request, as usual:
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest() .WithBucketName(bucketName) .WithKey(objectKey) .WithProtocol(Protocol.HTTPS) .WithExpires(DateTime.Now.AddMinutes(6)) .WithResponseHeaderOverrides(headerOverrides); string url = S3Client.GetPreSignedURL(request);
Finally, “fix” the resulting URL with the correct URL for your content type:
url = url.Replace(contentType, HttpUtility.UrlEncode(contentType));
Yes, this is a dirty workaround, but hey, this works for me! :)
source share