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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:15:28+00:00 2026-05-23T07:15:28+00:00

I store thumbnail images in Google App engine entities as BlobStoreProperties. Over time thumbnails

  • 0

I store thumbnail images in Google App engine entities as BlobStoreProperties. Over time thumbnails need to be updated, which I do by updating the content of these entities with fresh image data. However I found out that any subsequent retrieval of these images still returns the same old copy that was saved first time in the entity. It’s surprisingly inconsistent behavior. I wrote a simple standalone code to verify this.

Here are two simple handlers and a model definition. SaveImageHandler saves the image to datastore and LoadImageHandler retrieves it.

from google.appengine.ext import db
import logging

class Image(db.Expando):
 data = db.BlobProperty(required=True)
 uid = db.StringProperty(required=True) 

class SaveImageHandler(webapp.RequestHandler):                                
  def post(self, uid):                                                        
    imgdata = self.request.POST.get('imgdata').file.read()                    
    logging.error('Saving %d bytes'%(len(imgdata)))                           
    image = model.Image(data=imgdata, uid=uid)                                
    image.put()                                                               

class LoadImageHandler(webapp.RequestHandler):                                
  def post(self, uid):                                                        
    image = model.Image.gql('WHERE uid = :1', uid).get()                      
    self.response.headers['Content-type'] = 'image/png'                       
    logging.error('Loading %d bytes'%(len(image.data)))                       
    self.response.out.write(image.data)    

def application():
  return webapp.WSGIApplication([
    ('/_thumbsave/(.*)', SaveImageHandler),
    ('/_thumbload/(.*)', LoadImageHandler),
  ],debug=False)

def main():
  util.run_wsgi_app(application())

if __name__ == '__main__':
  main()

I upload an image like this

curl -F "imgdata=@/tmp/img1.png" http://ubuntu.local:8000/_thumbsave/X

I retrieve the image

curl -d dummy=0 http://ubuntu.local:8000/_thumbload/X > Downloads/imgout.png

imgout.png and img1.png are same

Then I upload another image img2.png

curl -F "imgdata=@/tmp/img2.png" http://ubuntu.local:8000/_thumbsave/X

Then retrieve it in same way above. I expect now imgout.png to be same as img2.png. But instead I find that it’s still the same old img1.png. Thus the Image query, returned stale object. The log statements that print the length of image, also verify that the image returned second time is not the updated one.

What’s going wrong here?

  • 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-23T07:15:28+00:00Added an answer on May 23, 2026 at 7:15 am

    In your SaveImageHandler you are creating a new Image entity each time you POST your image data, then you are just fetching the first image with that uid in your LoadImageHandler

    Change it to ‘find or create’ the image like:

    class SaveImageHandler(webapp.RequestHandler):
      def post(self, uid):
        image = Image.all().filter("uid =", uid).get()
        if not image:
            image = model.Image(uid=uid)
        image.data = self.request.POST.get('imgdata').file.read()
        image.put()
    

    Rather than using a uid property, think about using key_names for that purpose, and take a look at the get_or_insert method

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

Sidebar

Related Questions

I need to store phone numbers in a table. Please suggest which datatype should
I need to store app specific configuration in rails. But it has to be:
I have a general purpose file storage backed by Google App Engine Blobstore, when
I'm trying to provide an in-app Activity which displays thumbnails of photos in the
I store some time values in sqlite in %H:%M string format (for example 15:43),
I need to store products for an e-commerce solution in a database. Each product
I need to store user entered changes to a particular table, but not show
I need to store some sensitive data by encrypting it with atleast 128 bit
I am trying to build a script that retrieves a list of thumbnail images
Our application will be serving a large number of small, thumbnail-size images (about 6-12KB

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.