JavaScript SDK QuickStart
The JavaScript Client SDK provides simple APIs to access the OSS service.
This quickstart guide will show you how to install the client SDK and execute an example JavaScript program. For a complete list of APIs and examples, please take a look at the JavaScript SDK Reference section.
This document assumes that you have a working nodejs setup in place.

Download from NPM

1
npm install --save minio
Copied!

Using with TypeScript

1
npm install --save-dev @types/minio
Copied!

Initialize OSS Client

You need five items in order to connect to an OSS service.
Params
Description
endPoint
URL to object storage service (eg. http://storage-4175974314028753.cloud.bigconnect.io)
port
TCP/IP port number. This input is optional. Default value set to 443 for HTTPs.
accessKey
Access key is like user ID that uniquely identifies your account.
secretKey
Secret key is the password to your account.
useSSL
Always set this value to 'true' to enable secure (HTTPS) access
1
var OSS = require('minio')
2
3
var ossClient = new OSS.Client({
4
endPoint: 'storage-4175974314028753.cloud.bigconnect.io',
5
port: 443,
6
useSSL: true,
7
accessKey: 'Q3AM3UQ867SPQQA43P2F',
8
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG'
9
});
Copied!

Quick Start Example - File Uploader

This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket.
Make sure you have an OSS service running for this example.
1
var OSS = require('minio')
2
3
// Instantiate the minio client with the endpoint
4
// and access keys as shown below.
5
var ossClient = new OSS.Client({
6
endPoint: 'storage-4175974314028753.cloud.bigconnect.io',
7
port: 443,
8
accessKey: '4175974314028753',
9
secretKey: '4175974314028753'
10
});
11
12
// File that needs to be uploaded.
13
var file = '/tmp/photos-europe.tar'
14
15
// Make a bucket called europetrip.
16
ossClient.makeBucket('europetrip', 'default', function(err) {
17
if (err) return console.log(err)
18
19
console.log('Bucket created successfully.')
20
21
var metaData = {
22
'Content-Type': 'application/octet-stream',
23
'X-Amz-Meta-Testing': 1234,
24
'example': 5678
25
}
26
// Using fPutObject API upload your file to the bucket europetrip.
27
ossClient.fPutObject('europetrip', 'photos-europe.tar', file, metaData, function(err, etag) {
28
if (err) return console.log(err)
29
console.log('File uploaded successfully.')
30
});
31
});
32
Copied!

Run file-uploader

1
node file-uploader.js
2
Bucket created successfully.
3
4
osscli ls play/europetrip/
5
[2016-05-25 23:49:50 PDT] 17MiB photos-europe.tar
Copied!
Have a look at the JavaScript SDK Reference for more information.
Last modified 1yr ago