Aquí mi aporte en clases pasas el profe nos enseña a borrar un tweet pero nunca nos enseña a borrarlo de Firebase aquí el código…
if postRow.hasImage {
// 3. delete image to storage firebase
// create storage reference
let storageReference = Storage.storage().reference()
//Get file name
let fileNameString: String = (postRow.imageUrl as NSString).lastPathComponent
print(fileNameString)
let fileNameArray = fileNameString.split(separator: "?")
let fileName = fileNameArray[0]
print(fileName.replacingOccurrences(of: "%2F", with: "/"))
// Create a reference to the file to delete
let desertRef = storageReference.child(String(fileName.replacingOccurrences(of: "%2F", with: "/")))
// Delete the file
desertRef.delete { error in
if let error = error {
// Uh-oh, an error occurred!
print("Uh-oh, an error occurred!")
print(error)
NotificationBanner(title: "Uh-oh, an error occurred!", subtitle: error.localizedDescription, style: .danger).show()
} else {
// File deleted successfully
}
}
}
Los aportes, preguntas y respuestas son vitales para aprender en comunidad. Regístrate o inicia sesión para participar.