title: Drupal Services - Direct file URL instead of file resource reference
body: <p>I am using Drupal <em>services</em> and <em>services_entity</em> module to build a web service. The problem is that when a file is attached to an entity using fields, etc, the service endpoints display the file as resource reference as:</p>
  
  <pre><code>array (
      resource: file,
      id: xx,
      uri: /entity_file/xx.json
  )
  </code></pre>
  
  <p>The thing is, every time you wish to display a file you will have to make 2 or more requests:</p>
  
  <ul>
  <li>First, get the file entity URI</li>
  <li>Second, retrieve the details of the file entity by id to get the direct <em>url</em> for the file (which can be embedded into the application or used as src="xx" for an img tag.</li>
  </ul>
  
  <p>The question is, how to get the file URLs directly without having to make additional requests. So, the preferred response would be:</p>
  
  <pre><code>array (
      resource: file,
      id: xx,
      uri: /entity_file/xx.json,
      url: http://.../sites/.../files/foo/bar/b-reft.jpg
  )
  </code></pre>
  
  <p>I looked for hours but did not find an answer, so I thought I would share the solution I found. I believe it would help many (and I also wish I could share my module for complex index query parameter support for <em>services_entity</em> module).</p>