I'm using a handler to upload directly into my azure sql db.
Have adjusted web web config to allow 100mb and applicationhost config to allow everything seems to work ok. Files of various sizes upload fine until I try a file of 18MB. No errors reported, I get the little green light on the uploader but nothing actually gets into the DB.
Unsure where to start looking as no error gets reported.
Any ideas?
Handler code below if it helps....
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using Telerik.Web.UI;
public class Handler : AsyncUploadHandler
{
protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
{
System.IO.Stream fileStream = file.InputStream;
byte[] attachmentBytes = new byte[fileStream.Length];
fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length));
System.Data.SqlClient.SqlConnection conn = null;
try
{
try
{
conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["etb"].ConnectionString);
conn.Open();
System.Data.SqlClient.SqlCommand insertCommand = new System.Data.SqlClient.SqlCommand("INSERT INTO STAFF_DOC(FILENAME,FILESIZE,DOC,CONTENT_TYPE,SHORT_DESC,STAFF_ID) VALUES( @FileName, @FileSize, @FileData, @ContentType,'test',26)", conn);
insertCommand.Parameters.Add("@FileName", System.Data.SqlDbType.VarChar).Value = file.FileName;
insertCommand.Parameters.Add("@FileData", System.Data.SqlDbType.VarBinary).Value = attachmentBytes;
insertCommand.Parameters.Add("@ContentType", System.Data.SqlDbType.VarChar).Value = file.ContentType ;
insertCommand.Parameters.Add("@FileSize", System.Data.SqlDbType.VarChar).Value = attachmentBytes.Length;
int queryResult = insertCommand.ExecuteNonQuery();
}
catch (Exception ex){}
}
finally
{
if (conn != null)
{fileStream.Close();
conn.Close();}
}
return CreateDefaultUploadResult<UploadedFileInfo>(file);
}
}