Thuta Learning
Firebase Tutorial
AdvancedDevOps & Toolsအလယ်အလတ်

Download URL ရယူခြင်း

Firebase Tutorialသင်ခန်းစာ 22

Download URL ရယူခြင်း

Upload လုပ်ပြီးတဲ့ file ကို browser မှာပြချင်ရင် download URL ရယူရပါမယ်။ Image preview, avatar display, downloadable file link တို့မှာအသုံးဝင်ပါတယ်။

Code Example

javascript
import { getStorage, ref, getDownloadURL } from 'firebase/storage';

const storage = getStorage();

async function getAvatarUrl(userId, fileName) {
  const fileRef = ref(storage, 'avatars/' + userId + '/' + fileName);
  const url = await getDownloadURL(fileRef);

  console.log('Download URL:', url);
  return url;
}

Expected usage

ရလာတဲ့ URL ကို <img src="url"> ထဲထည့်ပြီး image ပြနိုင်သလို Firestore ထဲမှာ avatarUrl အနေနဲ့သိမ်းထားနိုင်ပါတယ်။

သတိထားရန်

Download URL ကို public share လုပ်နိုင်တဲ့ token ပါဝင်နိုင်ပါတယ်။ Private file တွေအတွက် access design ကိုသေချာစဉ်းစားပါ။

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Download URL ရယူခြင်း | Thuta Learning