admin管理员组文章数量:1326134
I'm saving images to my s3 bucket, generate a presigned URL and save that as a field in my model schema. When my frontend retrieves the model objects from the backend it uses that URL to retrieve the images.
The max expiration date you can set with v4 is 7 days. So what is the best practice to handle the "refreshing" of those URLs?
Things I thought about:
- Having a cron job in my backend that checks every e.g. every 24 hours if I have any URLs going invalid within the next 24h and generate a new one in case.
- Checking it everytime I receive a GET request and re-generate if it's invalid
- Not checking at all on the backend, and just try to the hit the URL on the frontend and if I get a 403 to then request the re-generation from the backend. I don't like this idea that much though as I couldn't simply use "/> but have to wrap it in some other logic.
I'm saving images to my s3 bucket, generate a presigned URL and save that as a field in my model schema. When my frontend retrieves the model objects from the backend it uses that URL to retrieve the images.
The max expiration date you can set with v4 is 7 days. So what is the best practice to handle the "refreshing" of those URLs?
Things I thought about:
- Having a cron job in my backend that checks every e.g. every 24 hours if I have any URLs going invalid within the next 24h and generate a new one in case.
- Checking it everytime I receive a GET request and re-generate if it's invalid
- Not checking at all on the backend, and just try to the hit the URL on the frontend and if I get a 403 to then request the re-generation from the backend. I don't like this idea that much though as I couldn't simply use "/> but have to wrap it in some other logic.
1 Answer
Reset to default 11The best practice is do not store pre-signed URLs.
Instead, generate them on-the-fly when they are required. They only take a couple of lines of code to generate, and generation does not involve a call to AWS.
So, whenever the app needs to reference a pre-signed URL, immediately generate and use it. There will be no need to worry about expiration times.
本文标签: javascriptBest practice to handle aws s3 presigned URL expiration dateStack Overflow
版权声明:本文标题:javascript - Best practice to handle aws s3 presigned URL expiration date - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742191082a2430226.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论