frame-one-bucket-adapter
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Frame One Table Logo NPM NPM GITHUB

Installation

npm

npm install frame-one-bucket-adapter

yarn

yarn add frame-one-bucket-adapter

Usage

S3

import S3 from "aws-sdk/clients/s3";
import {S3BucketAdapter} from "frame-one-bucket-adapter";

const s3 = new S3({
    accessKeyId: '/* access key here */', // For example, 'AKIXXXXXXXXXXXGKUY'.
    secretAccessKey: '/* secret key here */', // For example, 'm+XXXXXXXXXXXXXXXXXXXXXXDDIajovY+R0AGR'.
    region: '/* region here */' // For example, 'us-east-1'.
});

const bucket = new S3BucketAdapter({bucketName: '/* bucket name here */', s3});

const fileName = "test-image"

// upload file
await bucket.upload("/* file path or Buffer */", {fileName, contentType: "image/png"});

// check the file exists on the bucket
const exists = await bucket.exists(fileName);
if (!exists) {
    throw new Error("Could not find file.");
}

// create a read stream
const readStream = await bucket.createReadStream(fileName);

Google Storage

import {Bucket, Storage} from "@google-cloud/storage";
import {GoogleStorageBucketAdapter} from "frame-one-bucket-adapter";

const storage = new Storage({
    projectId: '/* project id here */',
    credentials: {
        client_email: '/* client email here */',
        private_key: '/* private key here */',
    }
});

const bucket = new GoogleStorageBucketAdapter({bucketName: '/* bucket name here */', storage});

const fileName = "test-image"

// upload file
await bucket.upload("/* file path or Buffer */", {fileName, contentType: "image/png", gzip: true});

// check the file exists on the bucket
const exists = await bucket.exists(fileName);
if (!exists) {
    throw new Error("Could not find file.");
}

// create a read stream
const readStream = await bucket.createReadStream(fileName, {validation: true});

Readme

Keywords

none

Package Sidebar

Install

npm i frame-one-bucket-adapter

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

37 kB

Total Files

15

Last publish

Collaborators

  • christopher_powroznik