@apolitical/storage

1.2.1 • Public • Published

Apolitical Storage

Node.js module to manipulate Apolitical's GCS (Google Cloud Storage) objects

Requirements

Requires the following to run:

Installation

Install with yarn:

yarn add @apolitical/storage

Usage

First of all, include @apolitical/storage module:

const apoliticalStorage = require('@apolitical/storage');

The recommended way to use @apolitical/storage is to create your own storage instance with the appropriate parameters:

const opts = { bucketName: 'some-bucket-name' };
const storageInstance = apoliticalStorage(opts);

The download function

The download function allows you to download an object from GCS:

  • It accepts the filePath parameter.
  • It returns the fileBuffer object (Node.js Buffer class)
const fileBuffer = await storageInstance.download('some/file/path.jpg');

The upload function

The download function allows you to upload an object to GCS:

  • It accepts the filePath and fileBuffer parameters.
  • It returns the fileURL string.
const fileURL = await storageInstance.upload(''some/file/path.jpg', fileBuffer);

Package Sidebar

Install

npm i @apolitical/storage

Weekly Downloads

17

Version

1.2.1

License

MIT

Unpacked Size

6.83 kB

Total Files

10

Last publish

Collaborators

  • npm-apolitical-styleguide