حذف الملفات باستخدام 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
  }
}];
    
وهي مفعّلة تلقائيًا.

معالجة الأخطاء

هناك عدة أسباب قد تؤدي إلى حدوث أخطاء عند حذف الملفات، بما في ذلك عدم توفّر الملف أو عدم توفّر إذن للمستخدم بحذف الملف المحدّد. يمكنك الاطّلاع على مزيد من المعلومات حول الأخطاء في قسم التعامل مع الأخطاء في المستندات.