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

cheers Ill have a read but I need to go cook some food first