# swifft

> An OpenStack Swift Client

Latest version **1.2.0** (published 2016-02-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install swifft
pnpm add swifft
yarn add swifft
bun add swifft
```

Provides the command `swifft`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2016-02-22 |
| First published | 2015-03-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Erik Toth |
| Maintainers | totherik |
| Keywords | openstack, swift, object, store |

## Links

- npm: https://www.npmjs.com/package/swifft
- Repository: https://github.com/totherik/swifft
- Issues: https://github.com/totherik/swifft/issues
- npm.io page: https://npm.io/package/swifft

## Dependencies (3)

- [wreck](https://npm.io/package/wreck.md) ^5.2.0
- [minimist](https://npm.io/package/minimist.md) ^1.1.0
- [babel-runtime](https://npm.io/package/babel-runtime.md) 4.7.16

## Recent versions

- 1.2.0 (latest) — 2016-02-22
- 1.1.0 — 2016-01-12
- 1.0.2 — 2015-05-06
- 1.0.1 — 2015-03-31
- 1.0.0 — 2015-03-30

## README

swifft
======
An OpenStack Swift Client npm module and CLI.

## Basic Usage
#### Programmatic API
```js
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
```bash
$ 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](http://developer.openstack.org/api-ref-objectstorage-v1.html) 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](http://developer.openstack.org/api-ref-objectstorage-v1.html) 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

---
_Source: https://npm.io/package/swifft · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
