I have generated a pre-signed url from S3 using the following .Net code (in a service that has the appropriate IAM role/permission for the bucket)
var key = GenerateKey(jobId, batchId);
var linkExpiresAt = _dateTimeService.Now().AddMinutes(_expiryTime);
var request = new GetPreSignedUrlRequest
{
BucketName = _bucketName,
Key = key,
Verb = HttpVerb.PUT,
ContentType = "application/json",
Expires = linkExpiresAt,
ServerSideEncryptionMethod = ServerSideEncryptionMethod.None
};
var url = _s3Client.GetPreSignedURL(request);
I can use this url in Postman to do a PUT with content 'JSON', but when I try to use it from code, I get 403
var content = new StringContent(mooStr, Encoding.ASCII, "application/json");
var fileStreamResponse = await httpClient.PutAsync(
url,
content);
Is there anything that stands out as wrong with the .Net attempt to PUT to the url?