My dilemma is that i need to retrieve the blob data stored in a table in oracle. I have created links with the data using jquery that link to a generic http handler blobHandler.ashx where i query the database for the file and return it to the user. This works for images which open in the browser but when it comes to other file types (pdf, word,excel), the program only downloads the .ashx file itself.
How do i get it to download the file with its extension?
using (OracleConnection objConn = new OracleConnection(conStr))
{
using (OracleCommand cmd = new OracleCommand())
{
cmd.Connection = objConn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT fl.file_content_type, fl.file_data,fl.file_name FROM fnd_lobs fl WHERE fl.file_id = " + mediano;
try
{
objConn.Open();
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
OracleBlob blob = dr.GetOracleBlob(1);
FileStream FS = new FileStream(dr["file_name"].ToString(), FileMode.Create);
Byte[] byteArr = new Byte[blob.Length];
int i = blob.Read(byteArr,0,System.Convert.ToInt32(blob.Length));
MemoryStream memStream = new MemoryStream(byteArr);
context.Response.AddHeader("Content-disposition: inline", "attachment; filename=" + dr["file_name"]);
context.Response.ContentType = dr["file_content_type"].ToString();
context.Response.OutputStream.Write(byteArr,0,i);
}
}
}
catch(Exception exe)
{
context.Response.Write(exe.Message);
}
finally
{
cmd.Dispose();
//pcur.Dispose();
objConn.Close();
objConn.Dispose();
context.Response.Flush();
context.Response.End();
}
}
}
I am using .net framework 1.1, visual studio 2003, oracle database version 10.3.0.5
thank you in advance for whatever advice you could provide this is my first question here.