
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
node-swiftclient
Advanced tools
A Node.js library for interacting with OpenStack Swift Object Storage. This library provides robust functionality for managing containers and objects, offering a clean and straightforward API for common Swift operations. It supports all Swift authenticati
A Node.js library for interacting with OpenStack Swift Object Storage. This library provides robust functionality for managing containers and objects, offering a clean and straightforward API for common Swift operations. It supports all Swift authentication versions (v1.0, v2.0, and v3).
Install the library using npm/pnpm:
npm install node-swiftclient
or
yarn install node-swiftclient
Here’s how to create a container, upload a file, and list its objects:
import { SwiftClient } from 'node-swiftclient';
import { Readable } from 'stream';
async function example() {
// Initialize SwiftClient
const client = new SwiftClient({
authVersion: 3,
authUrl: 'https://auth.example.com/v3',
userName: 'demo',
apiKey: 'demo',
tenant: 'test',
tenantDomain: 'Default',
domain: 'Default',
});
// Create a container
await client.createContainer('my-container', true, {
'X-Meta-Info': 'example',
});
// List containers
const containers = await client.listAllContainers();
console.log('Containers:', containers);
// Upload an object as a stream
const container = client.getContainer('my-container');
const stream = Readable.from('Hello, Swift!');
await container.putObject('docs/hello.txt', stream);
//List all object in pseudo-folder 'img'
const objects = container.listObjects({ prefix: 'docs/' });
console.log(objects);
// Download the object as a buffer
const buffer = await container.getObjectAsBuffer('docs/hello.txt');
console.log('Downloaded Content:', buffer.toString());
// Clean up: Delete the object and container
await container.deleteObject('docs/hello.txt');
await client.deleteContainer('my-container');
}
Method | Description |
---|---|
createContainer(containerName, publicRead, meta, extraHeaders) | Creates a new container with optional metadata and headers. |
getContainer(containerName) | Retrieves a SwiftContainer object for managing objects in a container. |
listAllContainers(query?, extraHeaders?) | Lists all containers with optional filters and headers. |
deleteContainer(containerName) | Deletes a container. |
getClientInfo() | Retrieves information about the authenticated Swift client. |
getContainerMeta(containerName) | Retrieves metadata for the specified container. |
Method | Description |
---|---|
listObjects(options?) | Lists objects in the container with optional filters (e.g., prefix , limit ). |
getObjectMeta(objectName) | Retrieves metadata for a specific object. |
patchObjectMeta(objectName, meta, extraHeaders?) | Updates metadata for an object. |
putObject(objectName, data, meta, extraHeaders) | Uploads an object using a buffer or stream with optional metadata and headers. |
deleteObject(objectName, when?) | Deletes an object, optionally scheduling its deletion for a future time. |
getObject(objectName) | Retrieves an object as a readable stream. |
getObjectAsBuffer(objectName) | Retrieves an object as a buffer. |
SwiftClient
supports multiple authentication methods. Examples:
const client = new SwiftClient({
authVersion: 1,
authUrl: 'https://auth.example.com/v1',
username: 'user',
password: 'pass',
tenant: 'tenant-id',
});
Note: Version 2 is deprecated and you should upgrade your swift storage.
const client = new SwiftClient({
authVersion: 2,
authUrl: 'https://auth.example.com/v2',
username: 'user',
password: 'pass',
tenant: 'tenant-id',
region: 'region-name',
});
const client = new SwiftClient({
authVersion: 3,
authUrl: 'https://auth.example.com/v3',
username: 'user',
password: 'pass',
tenant: 'tenant-id',
region: 'region-name',
});
This library is licensed under the MIT License.
FAQs
A Node.js client library for interacting with OpenStack Swift Object Storage
We found that node-swiftclient demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.