Resize S3 Images on the Fly with AWS Lambda, Amazon API Gateway - too many redirects for HTML IMG tag -
i've followed aws image resizing blog post resize images in s3 bucket on fly , return them when requested using bucket’s static website hosting endpoint. works fine me when type url web browser address bar.
i can see 2 redirects happening when (if resized image hasn't been generated yet): first, s3 endpoint 404 redirect api gateway url lambda function called generate resized image, , api gateway redirects browser endpoint url again. resized image there, gets displayed.
what i'm aiming display dynamically resized images in web pages, i've tried place endpoint url resized image in img tags eg. <img src="http://your_bucket_website_hostname_here/300×300/blue_marble.jpg">
when this, nothing shows in web pages. in browser console, can see error message - it's trying api gateway url, , error err_too_many_redirects
is there way me display resized images in web pages?
if not, need modify approach resize images predefined sizes upon upload s3 instead?
thanks!
make sure when configure url in environment variables not have / @ end of url cause looping in flow.
i.e http://bucket_name.s3-website.us-east-2.amazonaws.com (this good) i.e http://bucket_name.s3-website.us-east-2.amazonaws.com/ (this bad remove slash)
Comments
Post a Comment