title: How to load resources outside of classpath?
body: <p>I'm using spring framework in webapplication and I would like to load resources (*.jpeg) stored outside of classpath.</p>
  
  <p>I'm calling <code>GET</code> method of some controller. It works when I call the photo from classpath. But when I call paths like:
  <code>/ext/media/photos/photo.png</code>, <code>file:/ext/media/photos/photo.png</code>, <code>/home/user/ext/media/photos/photo.png</code>, <code>http://some-web-image</code>, it doesn't work.</p>
  
  <pre><code>@RequestMapping(value = "/loadPhoto", method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
  public ResponseEntity&lt;byte[]&gt; loadPhoto() throws IOException {
      InputStream in = servletContext.getResourceAsStream("/ext/media/photos/photo.png");
      return new ResponseEntity&lt;byte[]&gt;(IOUtils.toByteArray(in), HttpStatus.CREATED);
  }
  </code></pre>
  
  <p>I tried to map url to real location in spring context</p>
  
  <pre><code>&lt;mvc:resources mapping="/ext/media/photos/**" location="file:/home/user/ext/media/photos/"/&gt;
  </code></pre>
  
  <p>But I still can't get the resource. Is this right way how to get resource outside of classpath?</p>