Попробуйте этот пакет NPM, который делает работу довольно аккуратно https://www.npmjs.com/package/ibm-cos-sdk. Вот пример кода из npm пакета документов:
var AWS = require('ibm-cos-sdk');
var util = require('util');
var config = {
endpoint: '<endpoint>',
apiKeyId: '<api-key>',
serviceInstanceId: '<resource-instance-id>',
};
var cos = new AWS.S3(config);
function doCreateBucket() {
console.log('Creating bucket');
return cos.createBucket({
Bucket: 'my-bucket',
CreateBucketConfiguration: {
LocationConstraint: 'us-standard'
},
}).promise();
}
function doCreateObject() {
console.log('Creating object');
return cos.putObject({
Bucket: 'my-bucket',
Key: 'foo',
Body: 'bar'
}).promise();
}
function doDeleteObject() {
console.log('Deleting object');
return cos.deleteObject({
Bucket: 'my-bucket',
Key: 'foo'
}).promise();
}
function doDeleteBucket() {
console.log('Deleting bucket');
return cos.deleteBucket({
Bucket: 'my-bucket'
}).promise();
}
doCreateBucket()
.then(doCreateObject)
.then(doDeleteObject)
.then(doDeleteBucket)
.then(function() {
console.log('Finished!');
})
.catch(function(err) {
console.error('An error occurred:');
console.error(util.inspect(err));
});