An OpenStack Swift Client npm module and CLI.
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}`);
}
});
});
$ 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' } ]
Returns an Account instance.
Retrieve metadata for the current account.
Set metadata for the current account.
List containers for the current account.
Get the named container. Returns a Container instance.
Create the named container.
Retrieve metadata for the current container.
Set metadata for the current container.
List objects in the current container.
Delete the current container.
Get the named object. returns an Object instance.
Create the named Object.
Get the contents and settings of the current object.
Get the contents as a readable stream and settings of the current object. See Object Storage API Docs for valid Range values.
Get the contents as a readable range and settings of the current object. See Object Storage API Docs for valid Range values.
Retrieve metadata for the current object.
Set metadata for the current object.
Copy the current object to the provided destination: { container, object }.
Delete the current object.