Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does the Google App Engine python Blob care about what is stored in it
    text
    copied!<p>I have been struggling with some very basic understanding of how google app engine store data</p> <p>I have defined a class defining a client profile as such :</p> <pre><code>class ClientProfile(ndb.Model): nickname = ndb.StringProperty(required=True) photo = ndb.BlobProperty() uuid = ndb.StringProperty(required = True) </code></pre> <p>I retrieve an image data only uploading image.src via a POST using jquery.ajax(...)</p> <p>The data are properly sent to Google app engine and I can assign them to a variable with</p> <pre><code>imagesrc = self.request.get('photosrcbase64') </code></pre> <p>The data content is something looking like : </p> <pre><code>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... </code></pre> <p>So fare so good, the data is an image/png and the encoding is Base64, but should I care if it end in a Blob ?</p> <p>Now if I try to put the data in the photo Blob</p> <p>with for example :</p> <p><code>clientprofile.photo = imagesrc</code> I get a Bad Value Error, in this case :</p> <blockquote> <p>BadValueError: Expected str, got u'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAA</p> </blockquote> <p>I tried all kind of combinations using different solutions and get back all kind of BadValue or type errors.</p> <p>My question are : 1) Why does the Blob care, if it is a binary storage, I should be able to dump in it anything without having to interpret it and/or convert it, so is a Blob really a Binary/Raw storage and why does it care about how things are stored in it ?</p> <p>2) I have started having problems with this 2 years ago when still using db instead of ndb, I found a solution that I did not understand by stripping out the MIME information at the beginning of the data string, decoding the string Base64 and using db.Blob(...) to convert my string to a Blob. the problem is that db.Blob() does not seem to exist in ndb so I can't do this any more.</p> <p>I am convinced that I am missing something fundamental in the way informations are exchanged between google app engine and the browser and thank you in advance for a mind clearing answer</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload