वेब पर Cloud Storage का इस्तेमाल करके फ़ाइलें मिटाना

Cloud Storage में फ़ाइलें अपलोड करने के बाद, उन्हें मिटाया भी जा सकता है.

कोई फ़ाइल मिटाना

किसी फ़ाइल को मिटाने के लिए, पहले उस फ़ाइल की रेफ़रंस बनाएं. इसके बाद, उस पहचान फ़ाइल के लिए delete() तरीके को कॉल करें. इससे, समाधान होने वाला Promise दिखाता है. अगर Promise अस्वीकार करता है, तो गड़बड़ी का मैसेज दिखता है.

वेब मॉड्यूलर एपीआई

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!
});

वेब नेमस्पेसेड एपीआई

// Create a reference to the file to delete
var desertRef = storageRef.child('images/desert.jpg');

// Delete the file
desertRef.delete().then(() => {
  // File deleted successfully
}).catch((error) => {
  // Uh-oh, an error occurred!
});

गड़बड़ियां ठीक करना

फ़ाइल मिटाने पर कई वजहें हो सकती हैं. जैसे, फ़ाइल न होने पर या उपयोगकर्ता को अपनी पसंद की फ़ाइल मिटाने की अनुमति न होना. गड़बड़ियों के बारे में ज़्यादा जानकारी, दस्तावेज़ों के गड़बड़ियां मैनेज करना सेक्शन में मिल सकती है.