Xoá tệp bằng Cloud Storage trên các nền tảng của Apple
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 deleteWithCompletion: trên tham chiếu đó.
Swift
// Create a reference to the file to deleteletdesertRef=storageRef.child("desert.jpg")do{// Delete the filetryawaitdesertRef.delete()}catch{// ...}
Objective-C
// Create a reference to the file to deleteFIRStorageReference*desertRef=[storageRefchild:@"images/desert.jpg"];// Delete the file[desertRefdeleteWithCompletion:^(NSError*error){if(error!=nil){// Uh-oh, an error occurred!}else{// File deleted successfully}}];
Xử lý lỗi
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-01-29 UTC."],[],[]]