I used the following code to work on a site with private files:

   // check for favicon availability
-  $favicon = file_exists($dir .'/'. $domain .'.ico') ? (base_path().$dir .'/'. $domain .'.ico') : (base_path().drupal_get_path('module', 'urlicon') .'/favicon.ico');
+  $favicon = file_exists($dir .'/'. $domain .'.ico') ? (file_create_url($dir .'/'. $domain .'.ico')) : (base_path().drupal_get_path('module', 'urlicon') .'/favicon.ico');
   
   $link = theme_urlicon($match[3], $favicon, $match[1], array('alt' => '', 'title' => t('favicon'), 'class' => 'urlicon ui-'. $domain));
   return $link;
@@ -154,3 +154,12 @@
   $favicon = '<img src="'. $favicon .'" '. drupal_attributes($attributes) .' />';
   return l($text .' '. $favicon, $path, array(), NULL, NULL, TRUE, TRUE);
 }
+
+function urlicon_file_download($filepath) {
+  // Check if the file is controlled by the current module.
+  if (strpos($filepath, 'urlicon') !== FALSE) {
+    if (user_access('access content')) {
+      return array('Content-type: image/png');
+    }
+  }
+}

Comments

jonathan_hunt’s picture

Oops, I see I left the specific content-type in there; that needs to be made sensitive to the type of file being stored...

sanduhrs’s picture

Assigned: Unassigned » sanduhrs
Status: Active » Fixed

Commited to 5,6,HEAD
Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.