2017-09-30 15 views
0

写真、ビデオ、テキストのアップロードにfirebaseを使用します。 firebase(データベース&ストレージ) Firebase Database Consoleファイアベースからテキストを含む写真を削除する方法

static func uploadDataToServer(data: Data, videoUrl: URL? = nil, ratio: CGFloat, caption: String, Location: String, onSuccess: @escaping() -> Void) { 
    if let videoUrl = videoUrl { 
     self.uploadVideoToFirebaseStorage(videoUrl: videoUrl, onSuccess: { (videoUrl) in 
      uploadImageToFirebaseStorage(data: data, onSuccess: { (thumbnailImageUrl) in 
       sendDataToDatabase(photoUrl: thumbnailImageUrl, videoUrl: videoUrl, ratio: ratio, caption: caption, Location: Location, onSuccess: onSuccess) 
      }) 
     }) 

    } else { 
     uploadImageToFirebaseStorage(data: data) { (photoUrl) in 
      self.sendDataToDatabase(photoUrl: photoUrl, ratio: ratio, caption: caption, Location: Location, onSuccess: onSuccess) 
     } 
    } 
} 

static func uploadImageToFirebaseStorage(data: Data, onSuccess: @escaping (_ imageUrl: String) -> Void) { 
    let photoIdString = NSUUID().uuidString 
    let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("posts").child(photoIdString) 
    storageRef.putData(data, metadata: nil) { (metadata, error) in 
     if error != nil { 
      ProgressHUD.showError(error!.localizedDescription) 
      return 
     } 
     if let photoUrl = metadata?.downloadURL()?.absoluteString { 
      onSuccess(photoUrl) 
     } 

    } 
} 

答えて

0

Button most delete 3 Childs

@IBAction func DeletePost(_ sender: Any) { 

    let alert = UIAlertController(title: "Delete Post", message: "Are You Sure ?", preferredStyle: .alert); 

    alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)); 

    let okAction = UIAlertAction(title: "Delete", style: .default) {(action) in 


//.............Delete From Firebase Code 


    }; 
    alert.addAction(okAction); 

    self.present(alert, animated: true, completion: nil); 



} 
から情報を削除するために、私は簡単なボタンを追加する方法
関連する問題