Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Sau khi tải tệp lên Cloud Storage, bạn cũng có thể xoá các tệp đó.
Xoá tệp
Để xoá một tệp, trước tiên, hãy tạo một tệp tham chiếu đến tệp đó. Sau đó, hãy gọi phương thức delete() trên tham chiếu đó. Phương thức này sẽ trả về một Promise phân giải hoặc một lỗi nếu Promise từ chối.
Web
import{getStorage,ref,deleteObject}from"firebase/storage";conststorage=getStorage();// Create a reference to the file to deleteconstdesertRef=ref(storage,'images/desert.jpg');// Delete the filedeleteObject(desertRef).then(()=>{// File deleted successfully}).catch((error)=>{// Uh-oh, an error occurred!});
// Create a reference to the file to deletevardesertRef=storageRef.child('images/desert.jpg');// Delete the filedesertRef.delete().then(()=>{// File deleted successfully}).catch((error)=>{// Uh-oh, an error occurred!});
Có một số lý do khiến lỗi có thể xảy ra khi xoá tệp, bao gồm cả tệp không tồn tại hoặc người dùng không có quyền xoá tệp mong muốn. Bạn có thể xem thêm thông tin về lỗi trong phần Xử lý lỗi của tài liệu.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-02-21 UTC."],[],[]]