fileupload_firebase
v1.0.1
Published
upload files to firebase storage
Downloads
13
Readme
What is this?
Upload Files to Firebase Storage Easily.
Installation
npm i fileupload_firebase
or
yarn add fileupload_firebase
How To Use
import fileUploadFirebase from 'fileupload_firebase'
fileUploadFirebase(storage, files, path, setPercentage, success, setErrors)
storage = firebase storage
your need to create firebase project and get configurations and pass the storage function like bellow
import firebase from "firebase/app";
import "firebase/storage";
const firebaseConfig = {
apiKey: "****************************",
authDomain: "****************************",
databaseURL: "****************************",
projectId: "****************************",
storageBucket: "****************************",
messagingSenderId: "******************",
appId: "****************************"
};
firebase.initializeApp(firebaseConfig);
export default firebase;
export const storage = firebase.storage;
files = files: File[] you want upload to firebase storage, you need to pass files as an # array path = string, upload path in firebase storage setPercentage is a function to get upload percentage
let uploadPercentage;
const setPercentage = (percentage) => {
uploadPercentage = percentage;
}
success if a function which returns the uploaded urls
const success = (urls)=> {
console.log(urls)
}
```
setErrors is a function to get errors is there is any
let errors;
const setErrors = (error) => {
errors = error;
}
```