[英]How should I configure a Javascript Webapp so that it can use a Web Browser to view files in Google Cloud storage
My Javascript Webapp enables logged-in users to upload PDF files into the Google Cloud and store them in a Cloud Storage bucket. My Javascript Webapp 使登录的用户能够将 PDF 文件上传到 Google Cloud 并将它们存储在 Cloud Storage 存储桶中。 I'd like the wider public to be able to view the files they've just uploaded, but this is proving more difficult than I expected.
我希望广大公众能够查看他们刚刚上传的文件,但事实证明这比我预期的要困难。
An HTML button firing an onclick function for a window.open
call hard-coded with an HREF referencing the full Cloud Storage URL for the file together with an access token does the trick.一个 HTML 按钮为
window.open
调用触发 onclick 函数,使用 HREF 硬编码引用文件的完整 Cloud Storage URL 以及访问令牌就可以了。 I can get this information from the Storage tab in the Firebase console, but I'm at a loss to find a way of configuring this arrangement dynamically.我可以从 Firebase 控制台的“存储”选项卡中获取此信息,但我无法找到动态配置此安排的方法。
The URL part doesn't seem to be a problem, but I would appreciate advice on how I can obtain a suitable access token. URL 部分似乎不是问题,但我希望获得有关如何获得合适的访问令牌的建议。
Alternatively, can anyone suggest how I might lower the bar on GCP security settings for my Cloud Storage files so that a casual user doesn't need a token in the first place?或者,任何人都可以建议我如何降低我的云存储文件的 GCP 安全设置标准,以便临时用户首先不需要令牌? I have tried using the Cloud Security console to set permissions but have still to find a combination of settings that gives the desired outcome.
我曾尝试使用 Cloud Security 控制台设置权限,但仍需找到可提供所需结果的设置组合。
The answer is provided by Google's Make data public document.答案由 Google 的Make data public文档提供。
This tells you how to make either individual files or the entire content of a bucket publicly readable.这告诉您如何使单个文件或存储桶的全部内容公开可读。
In my case, the second approach was clearly what I needed.就我而言,第二种方法显然是我需要的。 I created a new bucket specifically for the content I wanted to share and followed the instructions closely - they're complex and easily misunderstood.
我专门为我想要分享的内容创建了一个新的存储桶,并严格按照说明进行操作——它们很复杂,很容易被误解。 At several points, you need to select settings from drop-down lists but, while these lists are populated, you don't see the items you're looking for until you start typing in the keywords detailed in the instructions.
在某些情况下,您需要从下拉列表中选择设置,但是当这些列表被填充时,在您开始输入说明中详述的关键字之前,您看不到要查找的项目。
With the new permission in place, my files were accessible by URLs of the form https://storage.googleapis.com/[Bucket name]/[File name]有了新的权限,我的文件可以通过https://storage.googleapis.com/[Bucket name]/[File name] 形式的 URL 访问
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.