Using get_serving_url() for a image stored as blob property in datastore

二次信任 提交于 2019-12-12 05:26:58

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14897836/using-get-serving-url-for-a-image-stored-as-blob-property-in-datastore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!