0.2.12 • Published 1 year ago

@mirochiu/firebase-storage-for-backend v0.2.12

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

@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

0.2.12

1 year ago

0.2.11

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago