1.0.3 • Published 3 years ago

frame-one-bucket-adapter v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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});
1.0.1

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.5

3 years ago

0.1.0

3 years ago