توضّح هذه الصفحة كيفية استخدام حزمة تطوير البرامج (SDK) لـ Cloud Storage for Firebase من أجل حذف الملفات التي تم تحميلها إلى حزمة 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 } }];
معالجة الأخطاء
هناك عدد من الأسباب التي قد تؤدي إلى حدوث أخطاء في عمليات حذف الملفات، بما في ذلك عدم وجود الملف، أو عدم حصول المستخدم على إذن لحذف الملف المقصود. لمزيد من المعلومات حول الأخطاء، يُرجى الاطّلاع على معالجة الأخطاء.