How do I alter the file link of an uploaded image in edit/create node form? When I upload an image in drupal, a file icon and a file name that links it to original file is created.

For example, I upload "foo.jpg" then 

 &lt;a href=path-to-file&gt;foo.jpg&lt;/a&gt;  


is generated. 

I want to change the path-to-file url because it's put putting base_url() + path-to-file which results in Not Found. I'm using amazon s3 for file storage.

I only want the path-to-file url without the base_url. Can anyone share some wisdom?
You could try implementing your own theme_file_link.


  Returns HTML for a link to a file.
  
  Parameters
  
  $variables: An associative array containing:
  
  file: A file object to which the link will be created. icon_directory:
  (optional) A path to a directory of icons to be used for files.
  Defaults to the value of the "file_icon_directory" variable.


Put this into your theme's template.php file:

function MYTHEME_file_link($variables){
  $file = $variables['file'];
  $icon_directory = $variables['icon_directory'];

  $url = file_create_url($file-&gt;uri);
  $icon = theme('file_icon', array('file' =&gt; $file, 'icon_directory' =&gt; $icon_directory));

  // Set options as per anchor format described at
  // http://microformats.org/wiki/file-format-examples
  $options = array(
    'attributes' =&gt; array(
      'type' =&gt; $file-&gt;filemime . '; length=' . $file-&gt;filesize,
    ),
  );

  // Use the description as the link text if available.
  if (empty($file-&gt;description)) {
    $link_text = $file-&gt;filename;
  }
  else {
    $link_text = $file-&gt;description;
    $options['attributes']['title'] = check_plain($file-&gt;filename);
  }

  return '&lt;span class="file"&gt;' . $icon . ' ' . l($link_text, $url, $options) . '&lt;/span&gt;';
}


Clear the cache, and then modify the code.

I would also investigate Amazon S3 Stream Wrapper