有没有一种简单的方法来托管您可以在 Google Cloud Platform 中读取和更新的 JSON 文档?
我想做的是托管一个 JSON 文档,本质上,该文档将充当 的托管版本json-服务器。我知道我可以使用 My JSON Server 执行类似的操作,但我计划移动我的整个架构都是 GCP,所以想更熟悉它。
起初,我研究了 Storage JSON API,但这似乎只是为了获取有关存储桶的数据,而不是存储桶中的项目本身。我创建了一个名为 test-json-api
的存储桶,并添加了一个 test-data.json
,但似乎无法通过此 API 访问 json 文件中的数据。
为了测试目的,我试图使其尽可能简单。随着时间的推移,我可能会使用 firestore 分配,但现在我想避免所有这些复杂性,而是对 json 文件进行简单的 GET 和 PUT/PATCH。
What I'm trying to do is host a JSON document that will then, essentially, serve as a hosted version of json-server. I'm aware I can do something similar with My JSON Server, but I plan to move my entire architecture to GCP so want to get more familiar with it.
At first I looked into the Storage JSON API, but it seems like that's just for getting data about buckets rather than the items in the buckets itself. I created a bucket called test-json-api
and added a test-data.json
, but there's seemingly no way to access the data in the json file via this API.
I'm trying to keep it as simple as possible for testing purposes. In time, I'll probably use a firestore allocation, but for now I'd like to avoid all that complexity, and instead have a simple GET and a PUT/PATCH to a json file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者您可以使用 JSON 托管服务,例如 JSONhost.com,您可以上传 JSON 并获取 GET 端点。另外,您还可以获得一个简单的表单来编辑 JSON 值,甚至不需要帐户
Or you can use a JSON Hosting service like JSONhost.com, you can upload a JSON and get a GET endpoint. Plus you get a simple form to edit the JSON values and it doesn't even require an account
您所说的 Storage JSON API 仅用于获取和更新元数据,而不是用于获取和更新对象内的数据。 Google Cloud Storage 存储桶内的对象不可变,并且是一种更新方式它们可能是在代码中从 Google Cloud Storage 存储桶中获取对象数据,更新它,然后再次将其上传到 Google Cloud Storage 存储桶中。
当您想要处理 JSON 文件时,可以使用 Cloud Datastore 进行探索 或 Cloud Firestore。另外,如果您想使用 Firebase,则可以探索 Firebase 实时数据库 。
The Storage JSON API you are talking about are only for getting and updating the metadata and not for getting and updating the data inside the object. Objects inside the Google Cloud Storage bucket are immutable and one way to update them may be to get the object data from Google Cloud Storage bucket within the code, updating it, then uploading it again into the Google Cloud Storage bucket.
As you want to deal with JSON files you may explore using Cloud Datastore or Cloud Firestore. Also if you wish to use Firebase then you may explore Firebase Realtime Database.
一种非常快速但肮脏的方法可以让您轻松读取 json 文档中的某些信息,即在 blob 名称中使用该信息。例如,关键信息
可以存储在名为“doc_3_my name”的对象中,以便在浏览存储桶时可以读取它。如果您需要查看所有原始数据,您可以下载正确的文档。对象名称最多可以是 1024 字节的 UTF-8(有一些例外),这通常足以显示基本信息。
请注意,您绝不应该以这种方式存储 PII。
https://cloud.google.com/storage/docs/objects
A very quick and dirty way to make it easy to read some of the information in the json doc is to use that information in the blob name. For example the key information in
could be stored in an object called "doc_3_my name", so that it can be read while browsing the bucket. You can then download the right doc if you need to see all the original data. An object name can be up to 1024 bytes of UTF-8 (with some exclusions), which is normally sufficient for surfacing basic information.
Note that you should never store PII like this.
https://cloud.google.com/storage/docs/objects