🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@ionq/storage-client

Package Overview
Dependencies
Maintainers
72
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionq/storage-client

A vendor-agnostic storage client for GCS, S3, and Signed URLs

latest
npmnpm
Version
1.0.1
Version published
Maintainers
72
Created
Source

Multi-Cloud Storage Client

This library provides a unified interface for interacting with different cloud storage providers, such as Google Cloud Storage (GCS) and Amazon S3.

Usage

createStorageProvider(type, options)

The createStorageProvider factory function is the primary way to create a storage provider instance.

  • type: The type of storage provider to create. Use the StorageProviderType enum (GCS or S3).
  • options: The configuration options for the specific provider. These are passed directly to the underlying SDK.

IStorageProvider

All storage providers implement the IStorageProvider interface, which defines the following methods:

  • get(bucket: string, path: string): Promise<Buffer>
  • getStream(bucket: string, path: string): Readable
  • put(bucket: string, path: string, content: Buffer | string): Promise<void>
  • putStream(bucket: string, path: string): Writable
  • delete(bucket: string, path: string): Promise<void>
  • list(bucket: string, prefix?: string): Promise<string[]>

Example

Google Cloud Storage (GCS)

import {
    createStorageProvider,
    StorageProviderType,
    StorageOptions,
} from '@ionq/storage-client';

const gcsOptions: StorageOptions = {
    projectId: 'your-gcp-project-id',
    keyFilename: '/path/to/your/keyfile.json',
};

const gcsProvider = createStorageProvider(StorageProviderType.GCS, gcsOptions);

async function runGCSExample() {
    const bucket = 'my-gcs-bucket';
    const path = 'my-file.txt';
    const content = 'Hello, GCS!';

    await gcsProvider.put(bucket, path, content);
    console.log('File uploaded to GCS.');

    const fileContent = await gcsProvider.get(bucket, path);
    console.log('File content from GCS:', fileContent.toString());
}

runGCSExample();

Amazon S3

import {
    createStorageProvider,
    StorageProviderType,
    S3ClientConfig,
} from '@ionq/storage-client';

const s3Options: S3ClientConfig = {
    region: 'us-east-1',
    credentials: {
        accessKeyId: 'YOUR_AWS_ACCESS_KEY_ID',
        secretAccessKey: 'YOUR_AWS_SECRET_ACCESS_KEY',
    },
};

const s3Provider = createStorageProvider(StorageProviderType.S3, s3Options);

async function runS3Example() {
    const bucket = 'my-s3-bucket';
    const path = 'my-file.txt';
    const content = 'Hello, S3!';

    await s3Provider.put(bucket, path, content);
    console.log('File uploaded to S3.');

    const fileContent = await s3Provider.get(bucket, path);
    console.log('File content from S3:', fileContent.toString());
}

runS3Example();

FAQs

Package last updated on 22 Oct 2025

Did you know?

Socket

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.

Install

Related posts