1.1.4 • Published 1 month ago

firebase-storage v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

firebase-storage

Easily operate Google cloud storage with a private key. Works with Edge runtime.

Sample

import { getStorage } from "firebase-storage";

const privateKey =
  "-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXXXXX-----END PRIVATE KEY-----\n";
const clientEmail =
  "firebase-adminsdk-XXXXX0XXXXX@XXXXXXX.iam.gserviceaccount.com";
const bucket = "XXXXXXXX.appspot.com"; // Can also be specified in each function
const parallels = 5; //default 1000

async function main() {
  const storage = getStorage({ privateKey, clientEmail, bucket, parallels });
  const file = new Blob(["Test value"], {
    type: "text/plain",
  });

  await storage
    .upload({
      published: true,
      name: "test",
      file,
      metadata: {
        cacheControl: "public, max-age=31536000, immutable",
      },
    })
    .then(console.log);
  await storage.list({ bucket }).then((objects) => objects.map(console.log));
  await storage.info({ name: "test" }).then(console.log);
  await storage
    .download({
      name: "test",
    })
    .then((v) => {
      console.log(new TextDecoder().decode(v));
    });
  await storage.del({ name: "test" }).then(console.log);
  await storage.infoBucket({ bucket }).then(console.log);
  await storage.updateBucket({ bucket, body: {} }).then(console.log);
}

main().catch(console.error);
1.1.4

1 month ago

1.1.3

1 month ago

1.1.2

2 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.0

5 months ago

0.0.9

5 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago