开发者

Dynamically serving images from Google App engine

having problems serving an image stored as a blob from google app engine - I'm trying to view a stored image with the following code

my datastore model is:

class QuestionTemp(db.Model):
     picture = db.BlobProperty()

my post call from the initial form is:

class QuestionAsker3(webapp.RequestHandler):
    def post(self):
      upload_files = self.request.get('file')  # 'file' is file upload
      tempQuestion = QuestionTemp(picture= db.Blob(upload_files))
      tempQuestion.put()
      self.response.headers['Content-Type'] = "image/jpeg"
      self.response.out.write(tempQuestion.picture)

The image is stored in the blobstore as I can view it in the GAE admin console "blob viewer".

In chrome the return screen in blank - fir开发者_高级运维efox I get a url and what looks to be a hashcode.

many thanks in advance.


managed to solve the problem - was reading the data into the Blobstore, rather than as a Blob so the Blob was just storing a references hence had no image data. The .value thing didn't work for me. Thanks for helping me figure it out @abdul and @adam

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜