title: Web2py: Serve images from action call or web service call
body: <p>I am using 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.</p>
  
  <p>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:</p>
  
  <pre><code>&lt;li class="file ext_jpg"&gt;
      &lt;figure class="image_container"&gt;
          &lt;img src="controller_name/action_serving_images/unique_id_genereted_for_this_image.jpg" alt=""&gt;
      &lt;/figure&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>having the Action:</p>
  
  <pre><code>def action_serving_images(image_id)
      #obtain image based on it's unique generated id
      return image
  </code></pre>
  
  <p>Or for the service case:</p>
  
  <pre><code>&lt;li class="file ext_jpg"&gt;
      &lt;figure class="image_container"&gt;
          &lt;img src="controller_name/service_serving_images/jpg/image/unique_id_genereted_for_this_image.jpg" alt=""&gt;
      &lt;/figure&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>having the Service:</p>
  
  <pre><code>def service_serving_images():
      return service()
  
  @service.jpg
  def image(image_id):
      #obtain image based on it's unique generated id
      return image
  </code></pre>
  
  <ol>
  <li>Is any of these options possible?</li>
  <li>How can I fetch the image and return it as a byte stream with the proper content-type so the browser can render it properly?</li>
  <li>Do i need to create a special decorator for JPG in the case of the Service? How?</li>
  </ol>