@mirochiu/firebase-storage-for-backend
TypeScript icon, indicating that this package has built-in type declarations

0.2.12 • Public • Published

@mirochiufirebase-storage-for-backend

installation

npm install @mirochiu/firebase-storage-for-backend

upgrade

npm install @mirochiu/firebase-storage-for-backend@latest

usage

cjs

const fs = require('node:fs');
const createClient = require('@mirochiu/firebase-storage-for-backend');

// please load your service account key
const serviceAccountKey = require('../serviceAccountKey.json');

// init the client for firebase storage
const client = createClient('<firebase-project-name>.appspot.com', serviceAccountKey);

console.log(client.bucketName);

(async () => {
    // upload to firebase storage
    await client.upload('test.json', fs.readFileSync('./package.json'));

    console.log('upload done');

    // read json from firebase storage
    console.log(await client.getJson('test.json'))
})();

mjs

import fs from 'node:fs';
import createClient from '@mirochiu/firebase-storage-for-backend';

// please load your service account key
import serviceAccountKey from './serviceAccountKey.json' assert { type: 'json' };

// init the client for firebase storage
const client = createClient('<firebase-project-name>.appspot.com', serviceAccountKey);

// upload to firebase storage
await client.upload('test.json', fs.readFileSync('./package.json'));
console.log('upload done');

// read json from firebase storage
console.log(await client.getJson('test.json'))

reference

Bucket API documentation

Package Sidebar

Install

npm i @mirochiu/firebase-storage-for-backend

Weekly Downloads

6

Version

0.2.12

License

MIT

Unpacked Size

13.3 kB

Total Files

9

Last publish

Collaborators

  • mirochiu