2017-09-30 2 views
0

나는 사진, 비디오 및 텍스트 업로드를 위해 firebase를 사용합니다. 내가 중포 기지에서 제거 정보를 간단한 버튼을 추가하는 방법 (데이터베이스 & 저장) Firebase Database Consolefirebase에서 텍스트가있는 사진을 삭제하는 방법

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); 



} 
관련 문제