Python – Upload files in Google App Engine


I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through db.TextProperty and db.BlobProperty.

I'll be glad anyone can provide code sample (both the client and the server side) on how this can be done.

Best Solution

In fact, this question is answered in the App Egnine documentation. See an example on Uploading User Images.

HTML code, inside <form></form>:

<input type="file" name="img"/>

Python code:

class Guestbook(webapp.RequestHandler):
  def post(self):
    greeting = Greeting()
    if users.get_current_user(): = users.get_current_user()
    greeting.content = self.request.get("content")
    avatar = self.request.get("img")
    greeting.avatar = db.Blob(avatar)