I'm using html and javascript and I want to download a file from S3 to local disk by using this solution
So I need node.js to use "require()" I'm not sure that I use a write way to create a script or not. Here is my code
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.9.0.min.js"></script>
<script src="./script/require.js"></script>
function loadfile(id){
//I have try
//var AWS = require('aws-sdk');
//but it not work so I use
const AWS = require(["https://sdk.amazonaws.com/js/aws-sdk-2.9.0.min.js"])
var s3 = new AWS.S3();
}
and right now the problem that I got is "AWS.S3 is not a constructor"
Why do you need require here? you have already added the aws-sdk.min.js file?
Try this:
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.9.0.min.js"></script> <script> function loadfile(id){ var s3 = new AWS.S3(); console.log( s3 ); } loadfile( 123 ); </script>
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.