Complete the code to initialize a reference to the Firebase Storage root.
let storage = Storage.storage()
let storageRef = storage.[1]Complete the code to upload data to a file named "image.jpg" in Firebase Storage.
let data = Data() let imageRef = storageRef.child("[1]") imageRef.putData(data, metadata: nil) { metadata, error in // handle completion }
Fix the error in the code to download data from Firebase Storage with a maximum size of 1MB.
let imageRef = storageRef.child("image.jpg") imageRef.getData(maxSize: [1]) { data, error in if let data = data { // use data } }
Fill both blanks to create a dictionary of file names and their sizes in bytes from metadata.
var fileSizes = [String: Int64]() for item in items { item.getMetadata { metadata, error in if let metadata = metadata { fileSizes[[1]] = metadata.[2] } } }
Fill all three blanks to delete a file named "oldfile.txt" from Firebase Storage and handle errors.
let oldFileRef = storageRef.child("[1]") oldFileRef.[2] { error in if let error = error { print("Failed to delete: \(error.localizedDescription)") } else { print("[3]") } }
