Code Monkey home page Code Monkey logo

frame-one-bucket-adapter's Introduction

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

frame-one-bucket-adapter's People

Contributors

metroxe avatar victorli2 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

frame-one-bucket-adapter's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.