Services Download API I am having difficulties setting up an endpoint with the services module to download a file. Ultimately I want the user to hit the services end point with something like /api/download/file/fid and it will download the file to the users machine. The reason I want to do it through services and not just get users to hit /sites/default/files/file.filetype is because I need to be able to restrict access to the download link with HTTP basic auth. I have tried searching but cannot find how to achieve this? any help is much appreciated. 

EDIT:
My xml response when I imported arpitr's endpoint configuration and called it.

&lt;result&gt;
    &lt;fid&gt;6&lt;/fid&gt;
    &lt;uid&gt;1&lt;/uid&gt;
    &lt;filename&gt;Transition1.jpeg&lt;/filename&gt;
    &lt;uri&gt;public://Transition1.jpeg&lt;/uri&gt;
    &lt;filemime&gt;image/jpeg&lt;/filemime&gt;
    &lt;filesize&gt;435007&lt;/filesize&gt;
    &lt;status&gt;1&lt;/status&gt;
    &lt;timestamp&gt;1475199010&lt;/timestamp&gt;
    &lt;type&gt;image&lt;/type&gt;
    &lt;uuid&gt;4c703ad2-290c-4573-9a29-a7e86e1a874e&lt;/uuid&gt;
    &lt;field_file_image_alt_text/&gt;
    &lt;field_file_image_title_text/&gt;
    &lt;rdf_mapping/&gt;
    &lt;metadata&gt;
        &lt;height&gt;2304&lt;/height&gt;
        &lt;width&gt;3072&lt;/width&gt;
    &lt;/metadata&gt;
    &lt;alt/&gt;
    &lt;title/&gt;
    &lt;height&gt;2304&lt;/height&gt;
    &lt;width&gt;3072&lt;/width&gt;
&lt;/result&gt;


I am missing &lt;file&gt; which is the content of the file base 64 encoded, any idea why this could be?
You can send an image through resources using base64_encode(), or _file_resource_retrieve().

I don't remember the specifics of it all, but here is how I did it for Services in a project last year. You'll have to dissect the code yourself, but it definitely does work:

/**
 * Override of the Services module File resource, retrieve method.
 *
  * The original method does not allow for the retrieval of an image with an image style.
  * This override accepts an additional parameter, $image_style, which if set will return
  * the file data for the image in that image style. This allows for the retrieval of private files.
  *
  * @param $image_style
  *   If this value is set to an image style, the data for the image in that image style will be returned.
  *   Otherwise, the original File resource is invoked.
  *
  * @see _file_resource_retrieve()
  */
 function ba_api_file_retrieve($fid, $include_file_contents, $get_image_style, $image_style)
 {
    if($image_style)
    {
        if ($file = file_load($fid))
        {
            $filepath = $file-&gt;uri;

            if($image_style == 'raw')
            {
                $return = base64_encode(file_get_contents(drupal_realpath($filepath)));
            }
            else
            {
                $return = base64_encode(file_get_contents(drupal_realpath(image_style_path($image_style, $filepath))));
            }
        }
        else
        {
            $return = 'file not found';
        }
    }
    else
    {
        module_load_include('inc', 'services', 'resources/file_resource');

        $return = _file_resource_retrieve($fid, $include_file_contents, $get_image_style);
    }

    return $return;
 }