I am trying to store 8 MB video files in a MySQL db using UniBlob and the method outlined in the UniDirect tutorial for blob storage. The blob storage works for small data files, 10K or so, but when I try to store a 8MB video file, I receive an "Database lost connection" error message.
The data item in the MySql table is defined as:
file_data LONGBLOB DEFAULT NULL
The code for storing the video file is (C# .NET):
FileStream fs = new FileStream(blobFilename, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
int streamLength = (int)fs.Length;
UniBlob uniBlob = db.getUniBlob();
uniBlob.Write(r.ReadBytes(streamLength), 0, streamLength);
string cmdString = "INSERT INTO eventData ";
cmdString += "(event_id, file_data) ";
cmdString += "VALUES(";
cmdString += "'" + eventList.eventID.ToString() + "',";
cmdString += ":file_data)";
UniCommand uCmd = db.GetCommand(cmdString, CommandType.Text);
UniParameter myParam = uCmd.Parameters.Add("file_data", UniDbType.Blob);
myParam.Value = uniBlob;
uCmd.ExecuteNonQuery();
Any suggestions of what I might be doing wrong?
Thanks for your help.
Blob Storage, DB looses connection
Fix for blob store size
The issue to the blob store size is a MySQL config parameter: max_allowed_packet = 1M in the my.ini file. This 1 megabyte setting was limiting the size of the blob I could store. Increasing the size on this parameter to something larger than the largest blob size to be stored fixed the problem.