MDP
2023-10-05 본문
- 초기 설정
// Firebase SDK 라이브러리 가져오기
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
import { getStorage } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-storage.js"
import { firebaseConfig } from "./config.js"
// Firebase 인스턴스 초기화
const app = initializeApp(firebaseConfig);
export const storage = getStorage(app);
- getStorage()
const storage = getStorage(app);
-
- storage를 가리키는 래퍼런스(포인터 같은 느낌)
- ref(storage, file.name)
const storageRef = ref(storage, file.name);
- storage 내부의 파일 위치를 가리키는 래퍼런스
- file.name은 storage 내부의 위치를 가리키도록 설정
- getDownloadURL(ref).then(url =>{})
import { getStorage, ref, deleteObject } from "firebase/storage"; const storage = getStorage(); // Create a reference to the file to delete const desertRef = ref(storage, 'images/desert.jpg'); // Delete the file deleteObject(desertRef).then(() => { // File deleted successfully }).catch((error) => { // Uh-oh, an error occurred! });
- file 데이터를 ref로 업데이트
- snapshot은 file에 대한 메타데이터
- deleteObject(desertRef).then(()=> {})
import { getStorage, ref, deleteObject } from "firebase/storage"; const storage = getStorage(); // Create a reference to the file to delete const desertRef = ref(storage, 'images/desert.jpg'); // Delete the file deleteObject(desertRef).then(() => { // File deleted successfully }).catch((error) => { // Uh-oh, an error occurred! });
- ex
- ex