
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
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:
swift = new SwiftClient({
authVersion: 1,
authUrl: 'http://example.com/auth/v1.0',
userName: 'tester2',
password: 'testing2',
tenant: 'test2',
});
Note: Version 2 is deprecated and you should upgrade your swift storage.
swift = new SwiftClient({
authVersion: 2,
authUrl: 'http://auth.example.com/v2.0',
userName: 'demo',
apiKey: 'demo',
tenant: 'test',
});
swift = new SwiftClient({
authVersion: 3,
authUrl: 'http://auth.example.com/v3',
userName: 'demo',
apiKey: 'demo',
tenant: 'test',
tenantDomain: 'Default',
domain: 'Default',
});
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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.