I thought the content type settings were handled automatically by the 
framework.
Anyway - for some reason setting the response.headers to 'image/jpeg' does 
not work - just get an empty/blank page. 
I must be  missing something else re handling gae blob properties - here's 
my test code:

Any further suggestions? 

Model:
# Image table - includes ref to image blob + lat/long for location/google 
map
db.define_table(
    'xim',
    Field('title', unique=True), 
    Field('image','upload'),
    Field('image_url'),
    
Field('modified_on','datetime',default=request.now,writable=False,readable=False)
    )

Controller:
def list_images():

    # Display Image as jpeg file - need to set HTTP Content type = 
image/jpeg in view
    images=db(db.xim.id>0).select(orderby=db.xim.title)
    response.headers['Content-Type']='image/jpeg' 
    
    return dict(images=images)

View:
  {{extend 'layout.html'}}
  
  <h3>Display Jpeg Images</h3>
  
  <table border="1">
    <tr>
       <th>Image Title</th>
       <th>Image Blob</th>         
    </tr>
    {{for img in images:}}
        <tr>
            <td>{{ =img.title }}</td>
            <td>{{=img.image_blob }}/</td>         
        </tr>
    {{pass}}
  </table>

Reply via email to