2

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"

WPN
  • 63
  • 1
  • 5

1 Answers1

1

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>
stefantigro
  • 452
  • 2
  • 12