0

So far I've been able to successfully use node.js, express, and knox to add/update/delete/retrieve objects in Amazon S3. Trying to move things to the next level I'm trying to figure out how to use knox (if it's possible) to do two things:

1) Set the object to use server-side encryption when adding/updating the object.

2) Get a particular version of an object or get a list of versions of the object.

ben75
  • 29,217
  • 10
  • 88
  • 134
Kelly Ford
  • 318
  • 2
  • 8
  • I wasn't able to find an answer for this - primarily because I believe it's not possible with knox as it stands. I tried modifying the source but was still too new the S3 API to create a workable solution. I finally found node-awssum (https://github.com/appsattic/node-awssum/) which has much more complete API coverage. Plus it works with other AWS services and additional services like Facebook and Twitter. – Kelly Ford Jun 11 '12 at 13:35

2 Answers2

2

I know this is an old question, but it is possible to upload a file with knox using server-side encryption by specifying a header:

client.putFile('test.txt', '/test.txt', {"x-amz-server-side-encryption": "AES256"}, function(err, res) {
    //Do something here
});
John Cook
  • 41
  • 3
1

Andy (who wrote AwsSum) here.

Using AwsSum, when you put an object, just set the 'ServerSideEncryption' to the value you want (currently S3 only supports 'AES256'). Easy! :)

e.g.

var body = ...; // a buffer, a string, a stream

var options = {
    BucketName    : 'chilts',
    ObjectName    : 'my-object.ext',
    ContentLength : Buffer.byteLength(body),
    Body          : body,
    ServerSideEncryption : 'AES256'
};

s3.PutObject(options, function(err, data) {
    console.log("\nputting an object to pie-18 - expecting success");
    console.log(err, 'Error');
    console.log(data, 'Data');
});
chilts
  • 451
  • 3
  • 12