在Google Cloud Datastore中使用URL安全键

huangapple go评论150阅读模式
英文:

Using URL-safe keys in Google Cloud Datastore

问题

我们正在从旧的AppEngine Datastore控制台迁移到新的Google Cloud Datastore控制台。在内部,我们有时需要生成指向特定数据存储实体的链接。

对于旧的GAE控制台,您可以使用编码的URL安全键链接到实体,例如:

return fmt.Sprintf("https://appengine.google.com/datastore/edit?key=%s", key)

其中key是实体的编码URL安全键。

然而,在新的云控制台中,当我尝试加载URL时,Google返回“加载失败”:

return fmt.Sprintf("https://console.cloud.google.com/datastore/entities/edit?key=%s", key)

其中key是实体的编码URL安全键。

如果我首先解码键并为URL提供命名空间和种类,它将加载,但仅限于实体查询页面(而不是编辑页面):

return fmt.Sprintf("https://console.cloud.google.com/datastore/entities/query?ns=%s&kind=%s&key=%s", namespace, kind, key)

但编码键的目的是不需要解码。

所以我的问题是:

有没有办法让新的云控制台接受编码的键并加载实体编辑页面?

英文:

We're migrating from the old AppEngine Datastore console to the new <a href="console.cloud.google.com/datastore" Google Cloud Datastore</a> console. Internally, we have times when we're trying to generate links to specific datastore entities.

For the old GAE console, you can use the encoded URL safe key to link to an entity, such as:

return fmt.Sprintf(&quot;https://appengine.google.com/datastore/edit?key=%s&quot;, key)

where key is the encoded URL-safe key from the entity.

However, in the new cloud console, Google returns "failed to load" when I try to load the URL:

return fmt.Sprintf(&quot;https://console.cloud.google.com/datastore/entities/edit?key=%s&quot;, key)

where key is the encoded URL-safe key from the entity.

It will load if I decode the key first and give the URL the namespace and kind, but only if it's the entity query page (not the edit page):

return fmt.Sprintf(&quot;https://console.cloud.google.com/datastore/entities/query?ns=%s&amp;kind=%s&amp;key=%s&quot;, namespace, kind, key)

But the purpose of an encoded key is to not have to decode that.

So my question:

Is there a way to get the new cloud console to accept the encoded key and load the entity edit page?

答案1

得分: 0

谷歌已更新控制台以正确处理URL安全键,因此此问题已解决。

英文:

Google has updated the console to correctly process URL-safe keys, so this issue is now solved.

huangapple
  • 本文由 发表于 2016年4月26日 03:41:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/36849637.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定