Aws-sdk S3 Upload Not Working From Mocha Test
Trying to run s3 upload from a mocha test: 'use strict'; describe('S3 test', function() { it.only('S3 test 1', function*() { var AWS = require('aws-sdk'); //AW
Solution 1:
Doh. Its asynchronous so I need to use the done callback:
'use strict';
describe('S3 test', function() {
it.only('S3 test 1', function(done) {
varAWS = require('aws-sdk');
//AWS.config.region = 'us-west-2';var s3 = newAWS.S3({
params: {
Bucket: 'mkruk-myBucket',
Key: 'myKey'
}
});
s3.createBucket(function(err) {
if (err) {
console.log("Error:", err);
done();
} else {
s3.upload({
Body: 'Hello!'
}, function() {
console.log("Successfully uploaded data to myBucket/myKey");
done();
});
}
});
});
});
Post a Comment for "Aws-sdk S3 Upload Not Working From Mocha Test"