Decipher Tools Blog

News about all things iOS, especially backup, recovery, and forensics. Upcoming features for Decipher TextMessage, Decipher Backup Repair, Decipher VoiceMail, and Decipher Backup Browser.

How to Handle Direct File Upload Google App Engine Python

Kelly Wilkerson | | categories: development, website/seo | View Comments

I searched my little heart out on the query "Python Direct File Upload Google App Engine" until I had given up hope thinking it was only doable in PHP. I finally stumbled on this blog post explaining how to handle uploads in webapp2 in python.

Here's how to handle direct file uploads in Google App Engine Python:

Step 1. Make sure your form tag includes enctype="multipart/form-data".

  <form action="yourHandlerUrl" class="form" method="POST" enctype="multipart/form-data">

Step 2. Add your file selector to your form.

      <input type="file" name="yourFileName" >

Step 3. In your form handler, instead of using self.request.get which will give you the file's name, use self.request.POST.get which will return a StringIO object.

fileObj = self.request.POST.get("yourFileName")

Step 4. Do what you need with it, such as iterate through the lines of the file:

for line in fileObj.file:
    #do cool stuff with line

Remember that there is a 32MB size limit on direct upload files.