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