简体   繁体   中英

Reading in a JSON from S3 bucket using javascript

I've tried to read about this but have not come up with anything yet. I have a JSON that gets output to an S3 bucket daily. I have a web app built in javascript that I'd like to be able to simply read in the JSON from the S3 bucket without downloading the JSON every day and re-committing in github, etc etc.

How does one read in a JSON that's hosted on an S3 bucket? Ideally, I'd like this to work like a live connection (rather than downloaded), since the JSON will be re-uploaded to S3 every day.

Is AWS SDK for javascript what I need? To clarify, this is an app built in vanilla javascript, not Node, so a simple-ish solution would be ideal... Thanks all.

The notion of a 'live connection' to S3 isn't practical, but an appropriate alternative would be to trigger your JavaScript code to run whenever a JSON file is uploaded to your S3 bucket.

To do that, write and deploy a simple Node.js Lambda function and configure S3 to trigger the Lambda function when a JSON file is uploaded. Your Lambda function would use the JavaScript SDK to get the JSON file and do whatever processing is required. Your Lambda function should be configured with an IAM role that permits it to get the uploaded object.

If you prefer to use a language other than JavaScript/TypeScript, see AWS Tools for the list of supported language SDKs and Lambda runtimes for the list of supported Lambda runtimes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM