I make a customized build here of the AWS SDK:
https://sdk.amazonaws.com/builder/js/
I can’t find any examples of how to use this in ReactJS. Can anyone please point me in the right direction?
I have tried putting this in my index.html
And in my ReactJS code replaced imoprt with var:
//import AWS from 'aws-sdk'
var AWS = require('aws-sdk')
But now my application does not even load – shows only the background image and does not load – absolutely zero shows in the Chrome console – no messages at all.
I can see in the Chrome network console that the custom sdk build is being loaded OK with a status 200 so that seems to be OK.
Can anyone suggest what I need to do please?
thanks
You cannot import a customized build of AWS SDK as a module. You’ll need to link it as an external js file in /public/index.html
:
<script src="PATH/TO/YOUR/CUSTOM/aws-sdk-{SDK_VERSION}.min.js"></script>
Then, you can access the global variable AWS
via window
object:
const AWS = window.AWS;
AWS.config.region = "YOUR_BUCKET_REGION";
const bucket = new AWS.S3({
params: {
Bucket: "YOUR_BUCKET_NAME"
}
});
Alternatively, instead of linking to customized SDK builds, you can always npm install aws-sdk
and then import individual AWS services as:
const S3 = require("aws-sdk/clients/s3");