How to make blob file downloadable? I have created a Module to make blob file available for Download in Drupal 7 .

Below my code for .module file

&lt;?php

function blobfile_block_info() {
  $blocks = array();
  $blocks['blobfile_block'] = array(
    'info' =&gt; t('Blob Files Download'),
  );

  return $blocks;
}

function blobfile_block_view($delta) {    

      $query = db_select('health_policy_document_upload_dtl', h)-&gt;fields('h');
      $result = $query-&gt;execute();

      $content ='';
      while($record = $result-&gt;fetchAssoc()) {

          $filename = $record['Document_Name'];
          $file     = $record['Document'];
          $type     = $record['Document_Type'];
          $size     = filesize($file);


          header("Content-length: $size");
          header("Content-type: $type");          
          header("Content-Disposition: attachment; filename=$filename");

          $content .= "&lt;a href='#'&gt;".$filename."&lt;/a&gt;";
          $content .= "&lt;br&gt;";
      }

    return array(
      'subject' =&gt; t('Bids'),
      'content' =&gt; $content
    );   

}


Please guide me where I went wrong.
I'm assuming you have already come up with a solution to upload the files and put them in the database, and that you have a good reason not to use Drupal's built-in file handling (I question that second assumption particularly given the reference to health policy but I'll grant it).

The block you created needs to just provide the list of links, but you should not set the headers there, just generate the links.  The link should probably be in the form of something like:  /custom_files/[filename]  (or something clearer based on your complete context.

First you need a hook_menu() to define the menu router to get your files. Something like:

function mymodule_menu() {
  $items['custom_files/%mymodule_filename'] = array(
    'page callback' =&gt; 'mymodule_filedownload',
    'page arguments' =&gt; array(1),
    'delivery callback' =&gt; 'mymodule_file_delivery',
  );
}


You should also add some permissions handling here, the documentation on hook_menu() explains how that works.  Also read the section on deliver callbacks because those also have security implications I'm glossing over.

Next you need the page callback function to actually send the file:

function mymodule_filedownload($mymodule_filename) {
   // Validate permissions
...
   // Validate filename
...
   // Load file object from database 
   $query = db_select('health_policy_document_upload_dtl', h)-&gt;fields('h')-&gt;condition('filename', $mymodule_filename,'=');
  $result = $query-&gt;execute();

   // Prep an array to hand data off to the delivery callback. It might just be the results, but often you want to tweak details...
...
  return $file_data_array;

}

function mymodule_file_deliver($file_data) {
   // Check $file_data to see if this is a valid file or an error of some kind.
...
  // Process and errors found and send proper error response.
...

  // Send file
  drupal_add_http_header("Content-length: ".$file_data['size']);
  drupal_add_http_header("Content-type: " .$file_data['type']);
  drupal_add_http_header("Content-Disposition: attachment; filename=".$file_data['filename']);

   print($file_data['data']);

   drupal_page_footer();
}


Obviously lots of details are glossed over here. In addition to hook_menu()'s documentation you likely will also want to read drupal_deliver_html_page().  Note the use of drupal_add_http_header() instead of PHP's header(), for most basic tasks Drupal has internal functions that provide some clean up and standardization to avoid basic mistakes and conflicts with other module; you should use them whenever possible.