0.10.1 • Published 7 months ago

@qbraid-core/storage v0.10.1

Weekly downloads
-
License
Proprietary
Repository
github
Last release
7 months ago

@qbraid-core/storage

Stable npm

Client for the qBraid Quantum storage service.

Installation

npm install @qbraid-core/storage

Usage Example

Upload a File

import { FileStorageClient } from '@qbraid-core/storage';

const client = new FileStorageClient();

const filePath = 'path/to/file.txt'; // existing file on the local filesystem
const namespace = 'my-namespace';
const objectPath = 'server/path/to/file.txt';
const response = await client.uploadFile(filePath, namespace, objectPath);

console.log(response);

Download a File

import { FileStorageClient } from '@qbraid-core/storage';

const client = new FileStorageClient();

const namespace = 'my-namespace';
const objectPath = 'server/path/to/file.txt';

const downloadResponse = await client.downloadFile(namespace, objectPath);

if (downloadResponse.stream) {
  const stream = downloadResponse.stream as Readable;
  let fileContents = '';

  stream.on('data', chunk => {
    fileContents += chunk;
  });

  stream.on('end', () => {
    console.log('File contents:', fileContents);
  });

  stream.on('error', err => {
    console.error('Error reading file stream:', err);
  });
} else if (downloadResponse.error) {
  console.error('Error downloading file:', downloadResponse.error);
}

License

This software is proprietary and subject to the terms of the qBraid Commercial Software License.