本文介绍了将get_serving_url()用作存储为数据存储区blob属性的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据存储将图像存储为blob属性。我想使用get_serving_url来即时提供图像。

  def urlserve(self):
return images.get_serving_url(str(self.key.urlsafe()), 350)

它给了我一个像

的网址

  http:// localhost:8097 / _ah / img / ahBkZXZ-cmFqaW5pbmF0aW9uciYLEglpbWFnZWxpc3QiDWRlZmF1bHRfaW1hZ2UMCxIDSW1nGKkHDA = s350 

但我无法使用该页面进行投放。所以我只能使用blobstore映像来做到这一点,如果是这样的话,我需要为我的映像创建一个blobstore并将blobreferenceproperty存储在我的数据存储中?或者有更好的方法吗?如果你使用 db ,你应该存储 blob_info.key() blobstore.BlobReferenceProperty 中,否则如果您使用 ndb 那么你应该在 ndb.BlobKeyProperty 中存储



对于图片服务网址,您不必一直计算它,但可以在存储<$ c的同时将其值存储到模型中$ c> BlobKey 。


I have a datastore storing images as a blob property. I want to use get_serving_url to serve images on the fly.

    def urlserve(self):
         return images.get_serving_url(str(self.key.urlsafe()),350)

It gives me a URL like

http://localhost:8097/_ah/img/ahBkZXZ-cmFqaW5pbmF0aW9uciYLEglpbWFnZWxpc3QiDWRlZmF1bHRfaW1hZ2UMCxIDSW1nGKkHDA=s350

But I can't able to serve using that page.

So I could only use blobstore image to do this, if so do i need to create a blobstore for my image and store the blobreferenceproperty in my datastore? Or is there better way?

解决方案

If you are using db then you should store the blob_info.key() in the blobstore.BlobReferenceProperty, otherwise if you're using the ndb then you should store the key in the ndb.BlobKeyProperty.

For the image serving URL you don't have to calculate it all the time, but you could simply store the value of it to your Model at the same time that you are storing the BlobKey.

这篇关于将get_serving_url()用作存储为数据存储区blob属性的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:40