开发者

Using blob properties in GAE

I need to save some binary data coming from post request. I'm doing:

obj.data=self.request.get('data')

And having the error: "Blob() argument should be str instance, not unicod"

I'm trying:

obj.data=str(self.request.get('d开发者_JAVA百科ata'))

And having: "ascii' codec can't encode character ...". What am I doing wrong? How to save raw data from request?


If you have binary data it's usually http post. I use a form class to save a submitted form to an entity:

data = AForm(data=self.request.POST)
entity = data.save(commit=False)


I solved the problem using base64 enconding for the parameter.


You're using a blob property, but attempting to store text in it, not raw bytes. You probably want to use a TextProperty, instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜