ibmcloud-objectstorage

0.1.7 • Public • Published

IBM Cloud Object Storage

ibmcloud-objectstorage is a npm to manage your files with Node.js

First Step

Use this link to create your container on IBM Cloud and retrieve your credentials IBM Cloud Object Storage

Usage

In your project root directory:

$ npm install ibmcloud-objectstorage -s

In your .js file, using the credentials you retrieved from the IBM Cloud console, fill the attributes inside config

var ObjectStorage = require('ibmcloud-objectstorage');
var config = {
    provider: 'openstack',
    useServiceCatalog: true,
    useInternal: false,
    keystoneAuthVersion: 'v3',
    authUrl: '',
    tenantId: '', //projectId from credentials
    domainId: '',
    username: '',
    password: '',
    region: '' //dallas or london region
};
var os = new ObjectStorage(config, "my-container");

ibmcloud-objectstorage uses the following functions, which are all promises:

create - Creates a container with the name you specified.

    os.create("my-container").then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    })

find - Retrieves all the files inside the container you specified.

    os.find().then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    })

findByName - Retrieves the file you specified, from the container.

    os.findByName('file.txt', './uploads/').then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    })

removeByName - Deletes the file you specified, from the container.

    os.removeByName('file.txt').then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    })

insert - Inserts the file you specified, on the container.

    os.insert('file.txt').then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    })

Licence

MIT

Author

Edison Cury Neto

Package Sidebar

Install

npm i ibmcloud-objectstorage

Weekly Downloads

1

Version

0.1.7

License

ISC

Last publish

Collaborators

  • edisoncury