Trouble with Programmatically Updating Media URLS in API to Cloudfront domain URL

Also this not exactly your case but have descent description