Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1838658
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:30:34+00:00 2026-05-17T06:30:34+00:00

I’m trying to learn the blobstore API… and I’m able to successfully upload files

  • 0

I’m trying to learn the blobstore API… and I’m able to successfully upload files and get them back, but I’m not having any luck trying to combine an upload form with a regular webform to be able to associated extra info with the file, such as a nickname for the file.

Below is the code for a simple app I’ve been playing with. It’s based on the sample google provides.

#!/usr/bin/env python
#

import os
import urllib

from google.appengine.ext import blobstore
from google.appengine.ext import webapp
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class StoredFiles(db.Model):
    nickname = db.StringProperty()
    blobkey = blobstore.BlobReferenceProperty()

    @staticmethod
    def get_all():
        query = db.Query(StoredFiles)
        files = query.get()

        return files


def doRender(handler, page, templatevalues=None):
    path = os.path.join(os.path.dirname(__file__), page)
    handler.response.out.write(template.render(path, templatevalues))

class MainHandler(webapp.RequestHandler):
    def get(self):

        allfiles = StoredFiles.get_all()

        upload_url = blobstore.create_upload_url('/upload')

        templatevalues = {
                'allfiles': allfiles,
                'upload_url': upload_url,

            }
        doRender(self, 'index.html', templatevalues)

class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        upload_files = self.get_uploads('file')
        blob_info = upload_files[0]

        self.redirect('/save/%s' % blob_info.key())

class SaveHandler(webapp.RequestHandler):

    def get(self, resource):

        newFile = StoredFiles()
        newFile.nickname = self.request.get('nickname')
        resource = str(urllib.unquote(resource))
        newFile.blobkey = resource

        newFile.put()

        self.redirect('/')

class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
    def get(self, resource):
        resource = str(urllib.unquote(resource))
        blob_info = blobstore.BlobInfo.get(resource)
        self.send_blob(blob_info)

def main():
    application = webapp.WSGIApplication(
          [('/', MainHandler),
           ('/upload', UploadHandler),
           ('/save/([^/]+)?', SaveHandler),
          ], debug=True)
    run_wsgi_app(application)

if __name__ == '__main__':
  main()

According to the docs, the blobstore handler is supposed to pass through the blob key and the rest of the form to the handler its redirected to… blob key is coming through just fine, but nothing else is.

Can someone please point out where I’m messing up or point me to a good tutorial describing this use case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:30:35+00:00Added an answer on May 17, 2026 at 6:30 am

    The problem is that your posted form data is lost when you redirect the request to “/save/%s”, which is normal.

    Instead of redirecting, you should put your code inside UploadHandler, like this (untested code) :

    class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
        def post(self):
            try:
                upload_files = self.get_uploads('file')
                blob_info = upload_files[0]
    
                newFile = StoredFiles()
                newFile.nickname = self.request.get('nickname')
                newFile.blobkey = blob_info.key()
                newFile.put()
    
                self.redirect('/')
            except:
                self.redirect('/upload_failure.html')
    

    See this page from the docs for a similar example : http://code.google.com/appengine/docs/python/tools/webapp/blobstorehandlers.html#BlobstoreUploadHandler

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.