【问题标题】:Dynamically serving images from Google App engine从 Google App 引擎动态提供图像
【发布时间】:2011-08-04 17:43:41
【问题描述】:

从谷歌应用引擎提供存储为 blob 的图像时遇到问题 - 我正在尝试使用以下代码查看存储的图像

我的数据存储模型是:

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

我在初始表单中的帖子调用是:

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)

图像 存储在 blobstore 中,我可以在 GAE 管理控制台中查看它 “斑点查看器”。
在 chrome 中,返回屏幕为空白 - firefox 我得到一个 url 和看起来像哈希码的内容。
非常感谢。

【问题讨论】:

  • 我认为您正在尝试直接查看回复。您是否将响应传递给 img 标签。
  • 没有理由不能返回图片。事实上,这正是当服务器满足浏览器在处理img 标记时发出的请求时应该发生的情况。

标签: image google-app-engine blob


【解决方案1】:

设法解决了问题 - 将数据读入 Blobstore,而不是作为 Blob 所以 Blob 只是存储一个引用,因此没有图像数据。 .value 的东西对我不起作用。 感谢您帮助我弄清楚@abdul 和@adam

【讨论】:

    猜你喜欢
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多