-
Notifications
You must be signed in to change notification settings - Fork 2
/
FirebaseUtils.js
63 lines (46 loc) · 1.8 KB
/
FirebaseUtils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { async } from '@firebase/util';
import { initializeApp } from 'firebase/app';
import { get, set, ref, getDatabase} from 'firebase/database';
import { getStorage, getDownloadURL, uploadBytes, ref as sRef } from "firebase/storage";
const firebaseConfig = {
apiKey: "AIzaSyAHhDR6w6sUoOznoB-IyW89Xo3UKqSTEGY",
authDomain: "padawandao.firebaseapp.com",
databaseURL: "https://padawandao-default-rtdb.firebaseio.com",
projectId: "padawandao",
storageBucket: "padawandao.appspot.com",
messagingSenderId: "1044973233400",
appId: "1:1044973233400:web:440ebb41e0f1a5dcdb070d",
measurementId: "G-VZ5TGGKHR3"
};
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
const FirebaseBucket = getStorage(app)
export async function GetPadawans() {
const val = await get(ref(database, "/padawans"))
.catch(err => console.log(err))
const padawans = await val.val()
return padawans
}
export async function GetPadawansTest() {
const val = await get(ref(database, "/test_padawan"))
.catch(err => console.log(err))
const padawans = await val.val()
return padawans
}
export async function AddPadawan(padawan) {
const dbref = ref(database, `test_padawan/${padawan.address}`)
const result = await set(dbref, padawan)
}
export async function GetPFP() {
const picture = "https://xpgcvlzgtrybnonxvfam.supabase.in/storage/v1/object/public/bucket/pfp/"
return picture
}
export async function uploadFile(file) {
// dis function uploads files dawg
const storageRef = sRef(FirebaseBucket, `testing/${file.name}`);
await uploadBytes(storageRef, file).then( async (snapshot) => {
console.log(snapshot)
});
const URL = await getDownloadURL(storageRef, `testing/${file.name}`)
return URL
}