I want to get to know the size of a file to decide if I'm going to make a GET request to download it or not. The file is in my AWS S3 Bucket.
I know that it is a good idea to make a HEAD request to the same URL, so it returns me the "Content-Length", although it is not avaliable by my frontend (javascript code running at the browser)
I've read that I need to set the header below to the HEAD response:
"Access-Control-Expose-Headers": "Content-Length"
I've also found out that I could use Lambda@Edge to add this header to the response, but I'm not using Cloudfront to serve this file. By triggering Lambda@Edge directly from S3 (as an event), I could not find a way to handle HEAD requests, only PUT, POST and DELETE in there.
Any ideas to include this header?