2016-05-31 4 views
2

Firebase Storage에 사진을 업로드하는 iOS 앱과 동일한 Firebase에 연결된 웹 앱이 있습니다. 웹에서 Storage의 변경 사항을 관찰 할 수있는 방법이 있습니까? 사진이 업로드 될 때 iOS 장치 자체 만 UploadTask에 액세스 할 수 있으며 on 이벤트 관찰자가 데이터베이스와 마찬가지로 저장소에 대해 the docs에 표시되지 않았습니다.Firebase Storage 업로드 이벤트 관찰 방법

답변

3

파이어베이스 스토리지는 실시간 데이터베이스와 동일한 "동기화"기능을 제공하지 않습니다 (1GB 객체를 동기화하려고하는 것처럼 상상해보십시오 ...). 당신은 메타 데이터를 동기화하기 위해 데이터베이스를 사용하는 것이 좋습니다과 같이 파일 업로드에 (예 : 다운로드하는 URL 등) :

// Upload file to Firebase Storage 
storageRef.putData(imageData).observeStatus(.Success) { (snapshot) in 
    // When the image has successfully uploaded, get it's download URL 
    let url = snapshot.metadata?.downloadURL()?.absoluteString 

    // Write data to the realtime database 
    dbRef.child("photos").childByAutoId().setValue(["name": snapshot.metadata?.name, "url": url]) 
} 

... 

dbRef.child("photos").observeEventType(.ChildAdded, withBlock: { (snapshot) -> Void in 
    // snapshot contains the name and URL of the uploaded file 
}); 

CodeZero to App에서이다, I/O 2016에서 우리가했던 이야기, 어떤 약간 더 자세히 자세히

관련 문제