是否有一种简单的方法来托管您可以在 Google Cloud Platform 中阅读和更新的 JSON 文档?

Is there a simple way to host a JSON document you can read and update in Google Cloud Platform?

我想做的是托管一个 JSON 文档,然后基本上用作 json-server. I'm aware I can do something similar with My JSON Server 的托管版本,但我计划将我的整个架构移至 GCP,因此想进一步熟悉它。

起初我查看了 Storage JSON API,但它似乎只是为了获取有关存储桶的数据,而不是存储桶中的项目本身。我创建了一个名为 test-json-api 的存储桶并添加了一个 test-data.json,但似乎无法通过此 API.

访问 json 文件中的数据

出于测试目的,我尽量保持简单。及时,我可能会使用 firestore 分配,但现在我想避免所有这些复杂性,而是使用简单的 GET 和 PUT/PATCH 到 json 文件。

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 和更新它们的一种方法可能是在代码中从 Google Cloud Storage 存储桶中获取对象数据,更新它,然后再次将其上传到 Google 云存储桶。

如果您想处理 JSON 个文件,您可以使用 Cloud Datastore or Cloud Firestore. Also if you wish to use Firebase then you may explore Firebase Realtime Database.

进行探索