在部署web2py应用程序时将图像存储在GAE python的数据存储区中 [英] Store images in datastore of GAE python while deploying web2py app
问题描述
我试图在GAE上部署一个web2py应用程序。在本地运行时,phone_details表在db.py中使用此行定义
db.define_table('phone_details',Field( '图像',类型= '上传'),场( '姓名',唯一=真),现场( 'screensiz'),现场( 'primcam'),现场( '处理器'),场( 'RAM'),字段('rom'),字段('os'),字段('company'),字段('price','integer'))
为了使它在GAE上运行,我在云数据存储中创建了一个名为'phone_details'的实体,但只允许使用字符串,布尔值,数字等数据类型,即图像不被允许。那么如何在该表的列中上传图像。我需要使用blobstore(从谷歌搜索,但我不知道如何使用它并连接到我在数据存储中定义的表)?
不是在GAE上自己定义实体,而是启用迁移,而web2py会自动为您的模型创建实体(您可以在创建实体的初始请求后禁用迁移)。
您会发现,在GAE上,web2py将定义与每个上传字段相关的其他blob字段。在你的情况下,它将生成一个名为 如果您想自己创建实体,请定义 I am trying to deploy a web2py application on GAE. When run locally, a phone_details table is defined in db.py using this line To make it run on GAE, I created an entity in cloud datastore naming it 'phone_details' but there only string,boolean,number etc. are allowed datatypes i.e image is not allowed. How to upload image in a column of that table then. Do I need to use blobstore (searched from google, but I don't know how to use it and connect to my table defined in datastore) ? Rather than defining the entity yourself on GAE, you can instead enable migrations, and web2py will automatically create entities for your models (you can disable migrations after the initial request that will create the entities). You will find that on GAE, web2py will define an additional blob field associated with each upload field. In your case, it will generate a field called If you want to create the entity on your own, define the 这篇关于在部署web2py应用程序时将图像存储在GAE python的数据存储区中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! image_blob
的字段,其中将存储实际文件(它将把文件名存储在 image $ c
图像字段,它只是一个字符串字段。 code>字段作为字符串类型,并创建
image_blob
字段。db.define_table('phone_details',Field('image',type='upload'),Field('name',unique=True),Field('screensiz'),Field('primcam'),Field('processor'),Field('ram'),Field('rom'),Field('os'),Field('company'),Field('price','integer'))
image_blob
where the actual file will be stored (it will store the filename in the image
field, which is just a string field).image
field as a string type, and create an image_blob
field.