The storage service of Medianova is Stook uses the AWS SDK.
For our customers to use this SDK with Stook, we have created a sample.js below.
This example shows how to;
set credentials up,
create a bucket
upload a file.
Install SDK
var AWS = require('aws-sdk');
Create S3 User
var config = { s3ForcePathStyle: true,}var credentials = new AWS.SharedIniFileCredentials({profile: 'medianova'});AWS.config.credentials = credentials;AWS.config.update(config);var ep = new AWS.Endpoint('*******.mncdn.com');var s3 = new AWS.S3({endpoint: ep});
Create Bucket and Upload Something
var bucketName = 'medianovatest';var keyName = 'hello_world.txt';s3.createBucket({Bucket: bucketName}, function() { var params = {Bucket: bucketName, Key: keyName, Body: 'Hello World!'}; s3.putObject(params, function(err, data) { if (err) console.log(err) else console.log("Successfully uploaded data to " + bucketName + "/" + keyName); });});
Config.json’s Contents
medianova@vm:~/aws-nodejs-sample$ more config.json -"accessKeyId": your_medianova_access_key,-"secretAccessKey": your_medianova_secret_key-"region": "us-east-1" }
You can also add different profile information with the credentials file under the “~ / .aws” directory.
In this case, you will not need 2 lines in the script given above.
var credentials = new AWS.SharedIniFileCredentials({profile: 'medianova'});AWS.config.credentials = credentials;Then run the same script as follows.wasabi@vm:~/aws-nodejs-sample$ AWS_PROFILE=medianova node sample.jsSuccessfully uploaded data to node-sdk-sample-38cb5413-29c2-46f5-ab2d-4ac4d553f929/hello_world.txt