GithubHelp home page GithubHelp logo

swifft's Introduction

swifft

An OpenStack Swift Client npm module and CLI.

Basic Usage

Programmatic API

import Swifft from 'swifft';

// These are the default env vars used internally by swifft.
// Usage here is for demonstration purposes only.
let options = {
    auth_url =      process.env.OS_AUTH_URL,
    tenant_id =     process.env.OS_TENANT_ID,
    tenant_name =   process.env.OS_TENANT_NAME,
    endpoint_type = process.env.OS_ENDPOINT_TYPE,
    region =        process.env.OS_REGION_NAME,
    username =      process.env.OS_USERNAME,
    password =      process.env.OS_PASSWORD
}


let account = Swifft.create(options);

// List containers
account.list((err, containers) => {
    // Print all container names and size
    for (let { name, bytes } of containers) {
        console.log(`${name}: ${bytes}`);
    }

    // List contents of first container.
    let [ { name: first } ] = container;
    account.container(first).list((err, objects) => {
        for (let { name, bytes } of objects) {
            console.log(`${name}: ${bytes}`);
        }
    });
});

CLI

$ source ~/openrc.sh

$ swifft list
[ { count: 1, bytes: 4, name: 'foo' },
  { count: 1, bytes: 4, name: 'bar' } ]

$ swift list foo
[ { hash: '<hash>',
    last_modified: '<date>',
    bytes: 4,
    name: 'foo2.txt',
    content_type: 'text/plain' } ]

API

Swifft

create([options])

Returns an Account instance.

Account

getMetadata(callback)

Retrieve metadata for the current account.

updateMetadata(metadata, callback)

Set metadata for the current account.

list([options], callback)

List containers for the current account.

container(name)

Get the named container. Returns a Container instance.

Container

create([settings], callback)

Create the named container.

getMetadata(callback)

Retrieve metadata for the current container.

updateMetadata(metadata, callback)

Set metadata for the current container.

list([options], callback)

List objects in the current container.

delete(callback)

Delete the current container.

object(name)

Get the named object. returns an Object instance.

Object

create([settings], callback)

Create the named Object.

get(callback)

Get the contents and settings of the current object.

getStream([range,] callback)

Get the contents as a readable stream and settings of the current object. See Object Storage API Docs for valid Range values.

getRange(range, callback)

Get the contents as a readable range and settings of the current object. See Object Storage API Docs for valid Range values.

getMetadata(callback)

Retrieve metadata for the current object.

updateMetadata(metadata, callback)

Set metadata for the current object.

copy(dest, callback)

Copy the current object to the provided destination: { container, object }.

delete(callback)

Delete the current object.

CLI Commands

swifft's People

Contributors

gmpify avatar totherik avatar wiserweb avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swifft's Issues

object.copy does not work.

Seems like there is a problem with copy... The request does not bring up any error, but it does not copy the object.

Could you add a putStream(readableStream) ?

Could you add a createStream(settings, callback(err, writableStream) ) that would create an object on a container using a stream ?
I'd like to avoid storing the data in memory before.
ex.

container.object(key).createStream( (err, objectStream) => {
  if(err) {
    res.sendStatus(500);
  } else {
    req.pipe(objectStream);
  }
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.