我有一个将照片上传到 Firebase 存储的 iOS 应用程序,以及一个连接到同一个 Firebase 的 Web 应用程序。有没有办法从网络上观察存储的变化?当上传照片时,只有iOS设备本身可以访问UploadTask,并且我没有看到on
事件观察者the docs https://firebase.google.com/docs/reference/对于存储,就像对于数据库一样。
Firebase 存储不提供与实时数据库相同的“同步”功能(想象一下尝试同步 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
});
Code https://gist.github.com/mcdonamp/cc45567cd95ba2a62017cb21e891effd来自零到应用程序 https://www.youtube.com/watch?v=xAsvwy1-oxE,我们在 I/O 2016 上所做的一次演讲,其中对此进行了更详细的介绍
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)