如何将Google数据存储用于我的网络应用程序,该程序不在Google应用程序引擎中托管? [英] How do I use Google datastore for my web app which is NOT hosted in google app engine?

查看:137
本文介绍了如何将Google数据存储用于我的网络应用程序,该程序不在Google应用程序引擎中托管?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网络应用程序中使用谷歌数据存储,但不想在谷歌应用程序引擎中托管它,我想将它托管在其他一台机器上。那么我如何在这种网络应用程序中使用数据存储?
会更经济吗?

解决方案

您需要遵循从其他平台访问Cloud Datastore API过程:


本节介绍如何激活和访问Google
Cloud之外的平台上运行的外部应用程序中的Cloud Datastore API


  1. 为项目启用Cloud Datastore API。您可以为现有项目启用API,或创建新项目,然后启用
    API。
    启用Cloud Datastore API


  2. 要使用Cloud Datastore API,您的Cloud项目需要一个活动的App Engine应用程序。打开App Engine仪表板和
    确认您的Cloud项目具有活动的App Engine应用程序。
    打开App Engine信息中心



    如果需要,创建一个App Engine应用程序。

  3. 转至创建服务帐户密钥页面。

    点击下面的服务帐户 strong>,然后点击新服务帐户 名称中输入服务帐户的名称。 使用默认的服务帐户ID 或生成一个不同的帐户。 键类型中选择 JSON
  4. 点击创建


  5. 创建成功后,您的浏览器将下载私钥。云平台控制台提供显示
    私钥文件名的提示。请注意文件名以便找到它,然后
    点击关闭关闭提示。

  6. 您的服务帐户是在服务帐户部分下显示的电子邮件地址 您的私钥是您刚刚下载的文件。

此时,所有服务和授权都为您的
项目,您可以开始编写代码或探索API。

您实际上不需要为GAE应用程序编写代码并部署它,请参阅访问数据存储区是否需要App Engine实例?



至于是否更经济(我认为与GAE上运行该应用程序相比) - 取决于很多关于应用程序的使用/规模,应用程序的功能和方式这样做。


I want to use datastore of google in my web app but do not want to host it in google app engine, I want to host it some other machine. So how i can use datastore in such web app ? will it be more economical ?

解决方案

You would need to follow the Accessing the Cloud Datastore API from another platform procedure:

This section shows how to activate and access the Cloud Datastore API from an external application running on a platform outside of Google Cloud.

  1. Enable the Cloud Datastore API for the project. You can enable the API for an existing project, or create a new project and then enable the API. Enable the Cloud Datastore API

  2. To use the Cloud Datastore API, your Cloud project requires an active App Engine application. Open the App Engine dashboard and confirm your Cloud project has an active App Engine app. Open the App Engine dashboard

    Create an App Engine app if needed. The app must not be disabled.

  3. Go to the Create service account key page.

  4. Click the drop-down box below Service account, then click New service account.

  5. Enter a name for the service account in Name.

  6. Use the default Service account ID or generate a different one.

  7. Select JSON in Key type.

  8. Click Create.

  9. Upon successful creation, your browser will download the private key. The Cloud Platform Console provides a prompt that displays the private key file name. Note the file name so you can locate it, then click Close to dismiss the prompt.

  10. Your Service Account is the Email address displayed under the Service Account section.

  11. Your Private Key is the file you just downloaded.

At this point all services and authorizations are configured for your project and you can start writing code or exploring the API.

You don't actually need to write code for the GAE app and deploy it, see Is an App Engine instance required for accessing Datastore?

As for being more economical or not (I presume compared to running the app on GAE) - it depends a lot on the app's usage/scale, what the app does and how it does it.

这篇关于如何将Google数据存储用于我的网络应用程序,该程序不在Google应用程序引擎中托管?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆