英文:
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("https://appengine.google.com/datastore/edit?key=%s", 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("https://console.cloud.google.com/datastore/entities/edit?key=%s", 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("https://console.cloud.google.com/datastore/entities/query?ns=%s&kind=%s&key=%s", 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论