Have ideas to improve npm?Join in the discussion! »

    TypeScript icon, indicating that this package has built-in type declarations

    2.0.2 • Public • Published

    Openstack Swift storage

    npm version Buy me a tree !

    This library is a simple wrapper over pkgcloud to be able to use the Swift storage provider from Openstack easily.

    A distributed object storage system designed to scale from a single machine to thousands of servers. Swift is optimized for multi-tenancy and high concurrency. Swift is ideal for backups, web and mobile content, and any other unstructured data that can grow without bound.

    How to install it

    • Install the package from npm with yarn add @adriantombu/openstack-swift
    • Instanciate the library in your script
    const swift = require('./lib').default.client({
      username: 'swift-username', // required
      password: 'swift-password', // required
      authUrl: 'swift-auth-url, // required
      region: 'swift-region'
      version: 'v3',
      keystoneAuthVersion: 'v3',
      domainName: 'Default'
    • Start using the library
    const container = await swift.getContainer('my-container')

    Container Model

    A Container for OpenStack has following properties:

      name: 'my-container',
      count: 1, // number of files in your container
      bytes: 12345, // size of the container in bytes
      metadata: { // key value pairs for the container
        // ...

    File Model

    A File for OpenStack has the following properties:

      name: 'my-file',
      container:  'my-container', // may be an instance of container if provided
      size: 12345, // size of the file in bytes
      contentType: 'plain/text' // Mime type for the file
      lastModified: Fri Dec 14 2012 10:16:50 GMT-0800 (PST), // Last modified date of the file
      etag: '1234567890abcdef', // MD5 sum of the file
      metadata: {} // optional object metadata

    Available methods

    swift.createContainer(container, metadata)

    Creates a new container with the name from argument container. You can optionally provide metadata on the request:

    swift.createContainer('my-container', {
      brand: 'bmw',
      model: '335i'
      year: 2009


    Retrieves the specified container from the current client instance.


    Removes the container from the storage account. If there are any files within the container, they will be deleted before removing the container on the client. result will be true on success.


    Retreives an array of file for the provided container.


    Removes all the file from the provided container.

    swift.getFile(container, filename)

    Retrieves the specified file details in the specified container from the current client instance.

    swift.downloadFile(container, filename)

    Returns a readable stream. Download a file from a container.

    swift.uploadFile(container, filename, data)

    Returns a writableStream. Upload a new file to a container.

    swift.removeFile(container, filename)

    Removes the provided file from the provided container.


    Returns an array containing the container informations and a list of file.

      container: { ... },
      containerFiles: [ ... ],

    How to contribute

    • Clone the repository git clone git@github.com:adriantombu/packages.git
    • Install the packages with yarn install
    • Modify the packages/openstack-swift/src/index.ts file
    • When everything's done, you can send a PR \o/


    npm i @adriantombu/openstack-swift

    DownloadsWeekly Downloads






    Unpacked Size

    20.4 kB

    Total Files


    Last publish


    • avatar