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 đó.
Kotlin
// Create a storage reference from our appvalstorageRef=storage.reference// Create a reference to the file to deletevaldesertRef=storageRef.child("images/desert.jpg")// Delete the filedesertRef.delete().addOnSuccessListener{// File deleted successfully}.addOnFailureListener{// Uh-oh, an error occurred!}
// Create a storage reference from our appStorageReferencestorageRef=storage.getReference();// Create a reference to the file to deleteStorageReferencedesertRef=storageRef.child("images/desert.jpg");// Delete the filedesertRef.delete().addOnSuccessListener(newOnSuccessListener<Void>(){@OverridepublicvoidonSuccess(VoidaVoid){// File deleted successfully}}).addOnFailureListener(newOnFailureListener(){@OverridepublicvoidonFailure(@NonNullExceptionexception){// 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."],[],[]]