views:

34

answers:

1

I want to server an image file but accept some attributes for processing before hand using Python and google app engine.

Where I would normally have

'http://www.domain.com/image/desiredImage.jpg'

as the image to server.

I want to be able to add some tracking to it so I can do something similar to

'http://www.domain.com/image/desiredImage.jpg?ref_val=customerID'

I figured the best way to do this would be to have a "proxy" for image requests like

'http://www.domain.com/imageproxy?img=imgID&ref_val=customerID'

and have the imageproxy url process the ref_val value and serve the image based off the imgID value from the datastore db.Blob value.

When I access the proxy URL it shows the image and processes fine. When I used the URL in other 3rd party javascript JSON requests looking for an image url, I get nothing to show up.

I guess the root of my question is how is accessing

'http://www.domain.com/image.jpg'

different from accessing

'http://www.domain.com/script_that_returns_image'

where the latter URL is a python script that outputs

    self.response.headers['Content-Type'] = 'image/jpeg'
    self.response.out.write(image)  #image a db.Blob property in google app engine
+1  A: 

Could be a couple issues. By overloading the image and providing arguments to it as if it were a script, you might be triggering javascript sandboxing/security stuff meant to prevent cross-site scripting attacks.

Another issue might be 'dumbness' of the client app, some clients might expect '.jpg' regardless of the content-type.

Open up your javascript console and see what error you're getting on the image in question as a first step.

Alternatively, you might want to be more devious about how you're encoding your uniqueness element, instead of making it CGI-ish, try something like

http://domain.com/image-ref_val-customerID.jpg, where customerID would be dynamically updated.

synthesizerpatel