I need to mock AWS S3 when using putObject().
When calling the function I need to create the file with user metadata values. I tried to find some code examples over the web, but I found only this base code:
var AWSMock = require('mock-aws-s3');
AWSMock.config.basePath = '/tmp/buckets/' // Can configure a basePath for your local buckets
var s3 = AWSMock.S3({
params: { Bucket: 'example' }
});
s3.putObject({Key: 'sea/animal.json', Body: '{"is dog":false,"name":"otter","stringified object?":true}'}, function(err, data) {
s3.listObjects({Prefix: 'sea'}, function (err, data) {
console.log(data);
});
});
Unfortunately, it's not includes the user metadata map.
In the parameters you're passing to the
putObject()
function, include aMetadata
key which contains key/value pairs of the metadata you want to store with the S3 object.Example:
See: putObject - Class: AWS.S3 — AWS SDK for JavaScript