I am using sharepoint object model to upload the files in Document library
but for uploading file and inserting metadata in document library it takes
for 1 MB file almost more than 1 minute
what will be possaible cause? I have almost 6000 document in document
library.
following is upload function code
-------------------------------------------------------------------
//function to upload a file to the sharepoint document library.
private void uploadmetadata(System.Web.UI.HtmlControls.HtmlInputFileFileField,
System.Web.UI.WebControls.CheckBox chkbox,string DeptChoice,string
DocumentLibraryFolder)
{
try
{
Stream imgStream;
int imgLen;
string imgUploadedName;
imgStream =FileField.PostedFile.InputStream;
imgLen = FileField.PostedFile.ContentLength;
imgUploadedName = FileField.PostedFile.FileName.Substring(
FileField.PostedFile.FileName.LastIndexOf("\\")+1 <file://%22)+1/>);
string url = "http://" + System.Environment.MachineName + "/sites/" +
siteName;
SPSite siteCollection = new SPSite(url);
SPWeb site = siteCollection.OpenWeb();
site.AllowUnsafeUpdates = true;
string tempReplace =DocumentLibraryFolder.Replace("(","");
string FinalDept = tempReplace.Replace(")","");
SPFolder DocLibFolder = site.GetFolder("http://" +
System.Environment.MachineName + "/sites/" + siteName + "/" + FinalDept);
byte[] imgBinaryData = new byte[imgLen];
int n;
n = imgStream.Read(imgBinaryData,0,imgLen);
string t3 =DateTime.Now.ToString();
SPFile file = DocLibFolder.Files.Add(imgUploadedName,
imgBinaryData,true); //Adding the file to Sharepoint Document Library.
//Adding metadata
file.Item["LoanNumber"] = tbLoanNumber.Value;
file.Item["FacID"] = tbFacID.Value;
file.Item["FacName"] = tbFacName.Value;
file.Item["ShortID"] = tbShortID.Value;
file.Item["IDR#"] = tbVaultN.Value;
file.Item["Department"] = FinalDept;
file.Item["LendGroup"] = tbLendGrp.Text;
file.Item["MainSection"] = DeptChoice;
file.Item["Section"] = chkbox.Text;
file.Item.Update(); //Adding the metadata of file.
imgStream.Close(); //releasing the objects
siteCollection.Close();
site.Close();
}
}