Quantcast
Channel: AWS Cloudfront Signed URL from Apex - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Paul for AWS Cloudfront Signed URL from Apex

$
0
0

You may want to implement the string replacement code found in both of those answers you referenced. I've run into similar issues generating presigned URLs for S3 and learned the (very) hard way about URL escaping reserved characters in the policy. In your code, you may want to try something like this:

...String policyEnc = EncodingUtil.base64Encode(Blob.valueOf(strpolicy));policyEnc = policyEnc.replace('+','-').replace('=','_').replace('/','~');...

Other languages (eg., Python in my case or .NET/Java in your case) seem to do a better job with this type of URL generation, but I've spent countless hours trying to debug this stuff in Apex in the past. Hope that helps!

Edit: just to be clear, the reason this should help (if not solve the issue) is because you're generating a presigned URL in the end, and that URL has to be properly formatted. If your base64-encoded policy includes characters normally found in URIs/URLs (eg., +, =, or /) it will fail.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>