On Dec 4, 8:34 pm, Chris Copeland <[email protected]> wrote:
> You must use urlfetch to http post to the blobstore upload handler.

Hi,

The below code seems to work. But now I want to pick up the data part
of an attachment and write that to the datastore.
http://stackoverflow.com/questions/4357022/writing-and-image-attachment-to-datastore-as-an-avatar-is-it-possible

Do you know how to do that?

Here's the code that I am using now with the form to write "img"
uploaded by the user:

class AvatarSave(webapp.RequestHandler):
    def post(self):
        userEmail = self.request.get("newUserEmail")
        q = User.all()
        q.filter("userEmail =", userEmail)
        qTable = q.fetch(10)
        if qTable:
            logging.info("qTable true")
            self.response.out.write("""<html><body>
              <form action="/avatar-save" enctype="multipart/form-
data" method="post">
                <div><label>Create your Avatar:</label></div>
                <div><input type="file" name="img"/></div>
                <input type="submit"/>
              </form>
            </body>
          </html>""")
            for row in qTable:
                avatar = images.resize(self.request.get("img"), 50,
50)
                row.avatar = db.Blob(avatar)
            db.put(qTable)
            self.redirect('/')
        else:
            logging.info("else user not found")
            self.redirect('/user-not-found')

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to