Hi!

I try to store a image in my google app engine application. I followed
this documentation: 
http://code.google.com/appengine/docs/python/images/usingimages.html

My db.Model:

class Image(db.Model):
  image = db.BlobProperty()
  name = db.StringProperty()

My Form:

    <p><form action="/insertImage" enctype="multipart/form-data"
method="post">
    <p>Name:<br/><input name="name" type="text" size ="30"></p>
    <p>Image:<br/><input name="file" type="file"/></p>
    <div><input type="submit" value="Insert"></div></form></p>



My insertImage class:

class insertImage(webapp.RequestHandler):
  def post(self):

    name = self.request.get('name')
    image = self.request.get('file')

    setImage(name, image)

    self.redirect('/')

def setImage(name, image):
    dbm = MyDbModel.Image()
    dbm.image = db.Blob(image)
    dbm.name = name
    dbm.put()

But after I click the "submit"-button of my online form I get this
error message:

google_appengine/google/appengine/api/datastore_types.py", line 1057,
in __new__
    type(arg).__name__)
TypeError: Blob() argument should be str instance, not unicode

I also tried "dbm.image = db.Blob(open(image).read())" in my setImage
class. Which I found here: 
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#Blob

But this result in this error:

google_appengine/google/appengine/tools/dev_appserver.py", line 1079,
in __init__
    super(FakeFile, self).__init__(filename, mode, bufsize, **kwargs)
IOError: [Errno 2] No such file or directory: u'MyImage.jpg'

Do you have an idea what's wrong?

Thanks a lot!
Markus
--~--~---------~--~----~------------~-------~--~----~
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