I am using Web2Py and need to serve images from folder external to Web2py,
user images are dynamical and have to be loaded from a different system in
the same server therefore they cannot be moved to be contained in the
web2py application directory. So I cannot have a relative path to the
images. Symbolink links are not an option.
I was thinking the solution could be to serve JPG images from an action
call or web service, this way the application can access the local file and
return it programatically without having to move a single image. For
example a view has the following code:
<li class="file ext_jpg">
<figure class="image_container">
<img src=
"controller_name/action_serving_images/unique_id_genereted_for_this_image.jpg"
alt="">
</figure>
</li>
having the Action:
def action_serving_images(image_id)
#obtain image based on it's unique generated id
return image
Or for the web service case:
<li class="file ext_jpg">
<figure class="image_container">
<img src=
"controller_name/service_serving_images/jpg/image/unique_id_genereted_for_this_image.jpg"
alt="">
</figure>
</li>
having the Service:
def service_serving_images():
return service()
@service.jpg
def image(image_id):
#obtain image based on it's unique generated id
return image
1. *Is any of these options possible?
*
2. *How can I fetch the image and return it as a byte stream with the
needed mime so the browser can render it properly?
*
3. *Do i need to create a special decorator for JPG in the case of the
Service? How?*
I posted the same question on
stackoverflow<http://stackoverflow.com/questions/17667679/web2py-serve-images-from-action-call-or-web-service-call>
but
no answer yet... I appreciate any help!
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.