Search code examples
node.jsamazon-web-servicesamazon-s3aws-sdk-js

Create a Bucket with HTML file from a Lambda (want HTML, get Octet Stream)


Geez, I thought this would be easy, but I'm stuck. I created a bucket with the AWS SDK, created a file in that bucket which I want to be an HTML file. I get an HTML file, but S3 insists that it has to be an Octet-steam. What I want is for it to render in a browser.

var params = {
    Bucket: myBucket,
    Key: myKey,
    Body: '<html>hi</html>',
    Metadata: {
        'Content-Type': 'Application/html'
    },
    ACL: 'public-read'
};
s3.putObject(params, function(err, data) {
    if (err) {
        console.log(err)
    } else {
        console.log("Successfully uploaded data to myBucket/myKey");
    }
});

Long story, but trying not to do it from the CLI


Solution

  • I believe your Content-Type should be text/html, not Application/html.