从 Google App 引擎动态提供图像
在从 Google 应用引擎提供存储为 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 和看起来是哈希码的内容。
非常感谢。
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 - firefox I get a url and what looks to be a hashcode.
many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设法解决问题 - 将数据读入 Blobstore,而不是作为 Blob
所以 Blob 只是存储引用,因此没有图像数据。 .value 的东西对我不起作用。
感谢您帮我弄清楚@abdul和@adam
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