Удаление файлов с помощью Cloud Storage на платформах Apple

После загрузки файлов в Cloud Storage вы также можете их удалить.

Удалить файл

To delete a file, first create a reference to that file. Then call the deleteWithCompletion: method on that reference.

Быстрый

// 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
  }
}];
    

Обработка ошибок

При удалении файлов могут возникать ошибки по ряду причин, включая несуществование файла или отсутствие у пользователя разрешения на удаление указанного файла. Более подробную информацию об ошибках можно найти в разделе «Обработка ошибок» документации.