i am trying to get a presigned url for a file(Royal Groups & Rosters-40052692020900-21894108859110.xlsx
)
string uploadObjectPath = "Royal Groups & Rosters-40052692020900-21894108859110.xlsx";
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
string preSignedURL = string.Empty;
s3Client = new AmazonS3Client(credentials);
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
{
BucketName = bucketName,
Verb = HttpVerb.PUT,
Key = System.Web.HttpUtility.UrlEncode(uploadObjectPath),
ContentType = contentType,
Expires = DateTime.Now.AddMinutes(30),
};
preSignedURL = s3Client.GetPreSignedURL(request);
but in the presigned url the filename was breaking after &(ampersand)
and replacing the rest with _(underscore)
I have seen aws docs saying to handle special characters(likely need to be URL encoded or referenced as HEX)
so i have changeed
Key = uploadObjectPath
to Key = System.Web.HttpUtility.UrlEncode(uploadObjectPath)
But with System.Web.HttpUtility.UrlEncode also it is breaking(Royal%2BGroups%2B?X-Amz-Expires=1800&....).
Is that wrong? If yes then how do we handle these special characters..
Thanks