1

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

saicharan
  • 435
  • 6
  • 18
  • "...it is not working." Very broad statement. Perhaps more detail? – Barns Jun 23 '20 at 14:18
  • @Barns, still the returned presigned url is breaking after & and returing like this(//abc.s3.us-east-1.amazonaws.com/users%2F200%2Femailattachments%2FRoyal%2BGroups%2B?X-Amz-Expires=1800&X...) – saicharan Jun 23 '20 at 14:41

0 Answers0