tro*_*ana 2 python google-app-engine image
我一直在尝试在GAE数据存储上保存图像,但是我收到以下错误:
"Blob()参数应该是str实例,而不是unicode".
任何想法如何通过这个?
我阅读和(尝试)编写图像的方式是:
...
avatar_data = self.request.get('pic_input') # pic_input is the name of the form
artist.picture = db.Blob(avatar_data) # artist is an entity type that has a picture field of type db.Blob()
...
Run Code Online (Sandbox Code Playgroud)
我还尝试将avatar_data包装在str()中,实际上将字符串保存在数据存储中但我的文件没有显示!
先感谢您 !
你想做什么?
响应pic_input
是一个unicode字符串,但你试图将它存储为只是二进制位.这些二进制位还是字符串?
如果它们是二进制位,则它们不应该首先被编码为unicode.
如果它是一个字符串,那么你不应该把它存储在Blob
一个Text
或一个或String
.
表单上载发送编码字符串(unicode)的原因是,您没有在表单中使用正确的enctype.
<form method = "post" enctype="multipart/form-data" >
Run Code Online (Sandbox Code Playgroud)
应该解决这个问题,你的代码才能正常工作.
归档时间: |
|
查看次数: |
807 次 |
最近记录: |