מחיקת קבצים באמצעות Cloud Storage בפלטפורמות של Apple

אחרי העלאת קבצים אל Cloud Storage, אפשר גם למחוק אותם.

מחיקת קובץ

כדי למחוק קובץ, קודם יצירת קובץ עזר לקובץ הזה. לאחר מכן קוראים לשיטה deleteWithCompletion: בהפניה הזו.

Swift

// Create a reference to the file to delete
let desertRef = storageRef.child("desert.jpg")

do {
  // Delete the file
  try await desertRef.delete()
} catch {
  // ...
}
    

Objective-C

// Create a reference to the file to delete
FIRStorageReference *desertRef = [storageRef child:@"images/desert.jpg"];

// Delete the file
[desertRef deleteWithCompletion:^(NSError *error){
  if (error != nil) {
    // Uh-oh, an error occurred!
  } else {
    // File deleted successfully
  }
}];
    

טיפול בשגיאות

יש כמה סיבות אפשריות לשגיאות במחיקת קבצים, כולל הקובץ לא קיים, או שלמשתמש אין הרשאה כדי למחוק את הקובץ הרצוי. מידע נוסף על שגיאות זמין טיפול בשגיאות של המסמכים.