@ejekanshjain/cloud-storage
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

cloud-storage

Import any one the client in your code base like this

import { AzureStorageClient } from '@ejekanshjain/cloud-storage'
import { GCPStorageClient } from '@ejekanshjain/cloud-storage'
import { S3Client } from '@ejekanshjain/cloud-storage'

Initialize storageClient like this

const s3Client = S3Client({
  region: process.env.AWS_REGION!,
  accessKey: process.env.AWS_ACCESS_KEY!,
  accessSecret: process.env.AWS_ACCESS_SECRET!,
  bucket: process.env.AWS_BUCKET!,
  host: process.env.AWS_HOST
})

Then you can call these methods to perform CRUD operations on file

await s3Client.addFile({
  filename: "test.txt",
  data: "Hello, World!"
})

await s3Client.getFile("test.txt")

await s3Client.deleteFile("test.txt")

You can use the similar approach for Cloudflare R2, GCP Buckets, Azure Storage Buckets, Firebase Storage

Troubleshoot gcp/firebase storage bucket for cors error on anonymous

Go to Cloud console Create a file cors.json

[
  {
    "origin": ["https://example.com"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
  }
]

Now run this command

gsutil cors set cors.json gs://exampleproject.appspot.com

Package Sidebar

Install

npm i @ejekanshjain/cloud-storage

Weekly Downloads

15

Version

3.2.0

License

MIT

Unpacked Size

33.4 kB

Total Files

35

Last publish

Collaborators

  • ejekanshjain