Uploading to an S3 bucket that contains dots using node SDK
I’m trying to host a static site in S3 using AWS. The problem is that for it to work with a custom domain, the bucket needs to be named like the domain. Domain names contains dots and for some reason they are not supported out of the box in the SDK. I was trying to something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var fs = require('fs');
var aws = require('aws-sdk');
var bucket = 'my.domain.com';
var bucketParams = {
params: {
Bucket: bucket
}
}
var bucket = new aws.S3(bucketParams);
var uploadData = {
ACL: 'public-read',
CacheControl: 'max-age=31556926',
Key: 'somefile.txt',
ContentType: 'text/plain'
};
uploadData.Body = fs.createReadStream('somefile.txt');
bucket.upload(uploadData).send();