I have been trying to save images on GAE data store but i get the following error:
“Blob() argument should be str instance, not unicode”.
Any ideas how to get past this ?
The way i read and (trying to) write the images is :
...
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()
...
I tried also to wrap avatar_data inside str() which actually got the string to be saved in the data store but my file didn’t display !!!
Thank you in advance !
What are you trying to do?
The response from
pic_inputis a unicode string, but you are trying to store it as if it were just binary bits. Are these binary bits or a string?If they are binary bits, they should not have been encoded to unicode in the first place.
If it is a string, then you shouldn’t store it in a
Blobbut aTextorString.The reason the form upload is sending an encoded string (unicode) is because, you did not use the proper enctype in the form.
Should solve this and your code will just work fine.