I’m generating a pre-signed-URL using the AWSSDK.S3 nuget from a .Net app using the code below.
var s3Client = new AmazonS3Client(<accessKeyId>, <secreAccessKey>, new AmazonS3Config
{
ServiceURL = <spacesEndpoint>
_});
var request = new GetPreSignedUrlRequest
{
BucketName = <bucketName>,
Key = <filePathKey>,
Expires = DateTime.UtcNow.AddMinutes(10),
ResponseHeaderOverrides = new ResponseHeaderOverrides
{
ContentDisposition = $"filename=\"{fileName}\"",
ContentType = <contentType>
}};
return _s3Client.GetPreSignedURL(request)
It works intermittently. In some cases, the generated URL is working and sometimes I get the error
<Error><Code>AuthorizationHeaderMalformed</Code><Message>The authorization header is malformed.</Message><Resource><do-space-file-path></Resource><RequestId>not available</RequestId></Error>
Has anyone encountered this before? Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
Indeed, as this is intermittent it can be quite tricky to troubleshoot. So what I could suggest here is:
If possible, configure your .NET app to generate detailed logs of the pre-signed URL generation process, including timestamps, headers, and the calculated signature. This can help pinpoint discrepancies.
Try to compare the working and failing requests. When you get a working URL and a failing URL, carefully compare their structures. Look for small differences in encoding, headers, or timestamps.
Try generating a pre-signed URL for the same object using the AWS CLI or another client. If this works, it can help eliminate bucket permission or endpoint configuration issues:
Let me know how it goes!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.