【发布时间】:2019-10-13 06:07:17
【问题描述】:
寻找有关如何使用只有经过身份验证的用户才能访问的图像设置 Google Cloud Storage 存储桶的说明。
我们的应用程序使用 Firstore 和 Cloud Storage。我们将图像存储在我们不希望在 NET 上公开可见的 GCS 存储桶中。 我们有设置存储规则
allow read: if request.auth.uid != null;
我们还在 Firebase 配置设置中配置了存储桶。 然后我们使用存储 API 来获取目标路径的 getDownloadURL()。 这有效,我们能够看到图像。但是,如果我们从页面复制图像 URL 并转到另一个浏览器(未登录),该浏览器就能够下载图像。
问题:配置和访问 GCS 存储桶的正确(也是最有效)方法是什么,以便只有使用 Firebase signInWithEmailAndPassword() 进行身份验证的经过身份验证的用户才能查看图像。
这是我们目前所做的(Angular 和 AngularFire)
// Assumes storage is an instance of the AngularFireStorage service
this.storage.getDownloadURL('/thumbs/imagename.jpg')
.subscribe(path => {
this.imgSrc = path;
});
如上所述,生成的路径是公开的,上述过程非常缓慢——图像需要很长时间才能出现在屏幕上。
我猜这不是正确的方法?
【问题讨论】:
标签: angular authorization google-cloud-storage firebase-storage