0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

I also found this after my post, it helped a lot: blog.katworksgames.com/2014/01/26/…
@MattHealy note also that the Content-Type header isn't sent as part of Metadata. What's shown in the question would create x-amz-meta-Content-Type. It needs to be a top-level key in params, named ContentType. docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/…
Thx Matt... I don't know where I found that code for the metadata tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.