There isn't anything special regarding serving files. This is all you
shuold need:
@expose(content_type=CUSTOM_CONTENT_TYPE)
def image(self, id):
image = Image.get(id)
pylons.request['Content-Type'] = image.mime_type
return image.data
Diez
And you can use the "mimetypes"-module to guess the mimetype based on
the file-suffix.
Diez
Did you bother reading my first answer?
Diez
If I may quote myself (from the *first* post I did in this thread):
"""
@expose(content_type=CUSTOM_CONTENT_TYPE)
def image(self, id):
image = Image.get(id)
pylons.request['Content-Type'] = image.mime_type
return image.data
"""
So, instead of "image.mime_type", "mimetyes.guess_type(filename)[0]".
Diez
It's supposed to be response, not request. That was a mistake on my side.
Diez