I’m using the following code with the AWSSDK.S3 nuget package:
public static string GetPreSignedURL(string filename, string displayFilename)
{
GetPreSignedUrlRequest request = new();
request.BucketName = BucketName;
request.Key = filename;
request.Expires = DateTime.UtcNow.AddHours(24);
request.Headers.ContentDisposition = "attachment; filename=" + displayFilename;
return client.GetPreSignedURL(request);
}
There are no errors running this on the the uploaded file to get a presigned URL, which is returned:
https://mydomain.ewr1.vultrobjects.com/86af3c37-2098-4301-90fc-f79c4c2d559d?AWSAccessKeyId=TWQVOAXAG4K34ITQPM7V&Expires=1719736648&Signature=vJ7ruIafjpEzH1gilFQUOYqnfOM%3D
Now I add the same content-disposition on the end so it will download with the filename I want:
https://mydomain.ewr1.vultrobjects.com/86af3c37-2098-4301-90fc-f79c4c2d559d?AWSAccessKeyId=TWQVOAXAG4K34ITQPM7V&Expires=1719736648&Signature=vJ7ruIafjpEzH1gilFQUOYqnfOM%3D&response-content-disposition=attachment; filename=test1.txt
But this gives an S3 error if I try to follow the link:
<Error>
<Code>SignatureDoesNotMatch</Code>
<RequestId>tx00000080074260b914ed7-00667fc9c3-67874bae-ewr1</RequestId>
<HostId>67874bae-ewr1-us</HostId>
</Error>
Any idea of how to set this up properly? Thanks.