1.0.3 • Published 2 years ago

@novo-x/google-storage v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Google Cloud Storage Service

Available methods

  • getAllBuckets: retrieves all buckets
  • getBucket: retrieves a bucket
  • createBucket: creates a bucket
  • deleteBucket: deletes a bucket
  • uploadFile: uploads a file
  • deleteFile: deletes a file
  • copyFile: copies a file between buckets
  • getSignedUrlForFile: retrieves a signed url for a file
  • downloadFileToMemory: downloads a file into memory
  • makeFilePublic: makes a file public
  • makeFilePrivate: makes a file private

Usage examples

yarn add @novo-x/googlecloud-storage

import {GoogleStorage} from "@novo-x/google-storage"

const MyService = new GoogleStorage({
    // optional storage options
});

const buckets = await MyService.getAllBuckets({
    // optional get options
});

const bucket = await MyService.getBucket(
    'my-bucket', // bucket name
    {
        // optional get options
    }
);

const createdBucket = await MyService.createBucket(
    'my-bucket', // bucket name
    {
        // optional creation options
    }
);

const deletedBucket = await MyService.deleteBucket(
    'my-bucket', // bucket name
    {
        // optional get bucket options
    },
    {
        // optional delete bucket options
    }
);

const uploadedFile = await MyService.uploadFile(
    'my-bucket', // bucket name
    'my-file', // file name
    {
        // optional get bucket options
    },
    {
        // optional upload options
    }
);

const deletedFile = await MyService.deleteFile(
    'my-bucket', // bucket name
    'my-file', // file name
    {
        // optional get bucket options
    },
    {
        // optional delete options
    }
);

const copiedFile = await MyService.copyFile(
    'my-bucket', // source bucket name
    'my-file', // file name,
    'other-bucket', // destination bucket
    {
        // optional get source bucket options
    },
    {
        // optional get destination bucket options
    }
);

const signedUrl = await MyService.getSignedUrlForFile(
    'my-bucket', // bucket name
    'my-file', // file name,
    {
        // required signed url options
    }
);

const downloaded = await MyService.downloadFileToMemory(
    'my-bucket', // bucket name
    'my-file', // file name,
    {
        // optional download options
    }
);

const privateFile = await MyService.makeFilePrivate(
    'my-bucket', // bucket name
    'my-file', // file name
    {
        // optional request options
    }
);

const publicFile = await MyService.makeFilePublic(
    'my-bucket', // bucket name
    'my-file' // file name,
);

Dependencies

@google-cloud/storage