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 435097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:20:30+00:00 2026-05-12T20:20:30+00:00

I’m trying to upload and save a resized image in a db.BlobProperty field on

  • 0

I’m trying to upload and save a resized image in a db.BlobProperty field on Google App Engine using Django.

the relevant part of my view that process the request looks like this:

image = images.resize(request.POST.get('image'), 100, 100)
recipe.large_image = db.Blob(image)
recipe.put()

Which seems like it would be the logical django equivalent of the example in the docs:

from google.appengine.api import images

class Guestbook(webapp.RequestHandler):
  def post(self):
    greeting = Greeting()
    if users.get_current_user():
      greeting.author = users.get_current_user()
    greeting.content = self.request.get("content")
    avatar = images.resize(self.request.get("img"), 32, 32)
    greeting.avatar = db.Blob(avatar)
    greeting.put()
    self.redirect('/')

(source: http://code.google.com/appengine/docs/python/images/usingimages.html#Transform)

But, I keep getting an error that says: NotImageError / Empty image data.

and refers to this line:

image = images.resize(request.POST.get('image'), 100, 100)

I’m having trouble getting to the image data. Seems like it’s not being uploaded but I can’t figure out why. My form has the enctype=”multipart/form-data” and all that. I think something’s wrong with how I’m referring to the image data. “request.POST.get(‘image’)” but I can’t figure out how else to reference it. Any ideas?

Thanks in advance.

  • 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-12T20:20:30+00:00Added an answer on May 12, 2026 at 8:20 pm

    After some guidance from “hcalves” I figured out the problem. First of all, the default version of Django that comes bundled with App Engine is version 0.96 and how the framework handles uploaded files has changed since then. However in order to maintain compatibility with older apps you have to explicitly tell App Engine to use Django 1.1 like this:

    from google.appengine.dist import use_library
    use_library('django', '1.1')
    

    You can read more about that in the app engine docs.

    Ok, so here’s the solution:

    from google.appengine.api import images
    
    image = request.FILES['large_image'].read()
    recipe.large_image = db.Blob(images.resize(image, 480))
    recipe.put()
    

    Then, to serve the dynamic images back again from the datastore, build a handler for images like this:

    from django.http import HttpResponse, HttpResponseRedirect
    
    def recipe_image(request,key_name):
        recipe = Recipe.get_by_key_name(key_name)
    
        if recipe.large_image:
            image = recipe.large_image
        else:
            return HttpResponseRedirect("/static/image_not_found.png")
    
        #build your response
        response = HttpResponse(image)
        # set the content type to png because that's what the Google images api 
        # stores modified images as by default
        response['Content-Type'] = 'image/png'
        # set some reasonable cache headers unless you want the image pulled on every request
        response['Cache-Control'] = 'max-age=7200'
        return response
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Paperclip to handle profile photo uploads in my app. They upload
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
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
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.