Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Uploading files in SharePoint Doc Lib taking to much time

  Asked By: Damaris    Date: Nov 27    Category: Sharepoint    Views: 4297

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

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
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/" +
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



6 Answers Found

Answer #1    Answered By: Donnie Drake     Answered On: Nov 27

Once you go beyond 500 items in a list, the upload time  becomes slower.
At 2,000 items, the upload  time is unbearable.

I believe it is because it must iterate through the entire list to see
if the filename already exists. The only way I know to speed this up is
by using folders to segment the uploads.

Answer #2    Answered By: Nathaniel Henderson     Answered On: Nov 27

It slows down because WSS loads the entire collection of ListItems into
RAM (not the documents themselves but all the metadata  about the

Answer #3    Answered By: Tanner Moss     Answered On: Nov 27

Can I use that in a book?????????????

Answer #4    Answered By: Bobby Boyd     Answered On: Nov 27

any white paper or document  reference is there for this ?

Actually I tested this scenario on Test server for empty document library  is
is very fast upload  compared to
document library having 6000+ documents.
any performance improvement by coding or any other approach for this?

Answer #5    Answered By: Sean Perez     Answered On: Nov 27

The only paper I'm aware of with any more detail than the typical 1.
keep containers below 2000 items, 2. use indexed columns for view
filters, and 3. use folders to increase the number of containers in a
given list/library is the TechNet white paper: Working with large lists
in Office SharePoint Server 2007:

Answer #6    Answered By: Freddy 96     Answered On: Jan 04

Have you ever tried LongPathTool??
Try it it will surely be helpful..