Solved

Attaching files to a Sharepoint Library

Posted on 2010-08-23
4
601 Views
Last Modified: 2012-06-22
Is there any way of attaching additional files to a document library in sharepoint.  I have looked at various approaches, including attaching the file to an InfoPath Form that is the basis for the library, but it's a bit wooden.  I just want to make sure I am not missing an obvious solution.
0
Comment
Question by:RichShare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 33501124
If you want to attach multiple files at one time there is 3 ways of doing this...

1st - You can use SharePoint Designer to accomplish this, Navigate to your document library and upload your files (SharePoint Designer has a maximum of 50MB per transfer)

2nd - Open your document library in Sharepoint and click Upload drop down (upload multiple documents)

3rd - Easiest way to do this is via Windows Explorer, Navigate to your sharepoint document library Under Actions, click click "Open with Windows Explorer"

Hope this helps~!
0
 

Author Comment

by:RichShare
ID: 33501398
Thank you for the prompt response.  What I meant was once the document/item is in the library I want to attach additional supporting files (e.g. pdf, etc.) to support that one library item.  I understand this is possible with a list but the concept of a template library really works for what we want to do but because we require additional signatures we have to scan a signed copy of the document back in to the library/list.  Hope that makes sense?
0
 
LVL 2

Accepted Solution

by:
ibliskavka earned 125 total points
ID: 33510155
Wow, looking back at all this text I guess it was worth first asking if you were interested in a code example...
_____

What I am suggesting will require code. It is not terribly difficult to implement if you have access to a programmer or can do it yourself.

Attaching a file to the form is a great idea but in our case, versioning bloated the library excessively.

Our users attach a file directly to the form, on submit the file data field is passed to a webservice as a string parameter. The webservice decodes the file and saves it to a separate Quotes document library. The webservice then returns a link to that attachment as a return value. Upon receiving the link, the form adds the link to a repeating table of attachments links and clears the form's attachment field. Then the form is submitted to the document library.

This allows us to use as many attachments as we want without actually storing the files in the form which helps with opening time and our storage requirements.

The class for decoding/encoding infopath attachments is located at:
http://support.microsoft.com/kb/892730

There is a bunch implementation examples on the web for it. I attached my WS function below.
This is a simplified function, the return value should probably be encoded as a HTML link before saving it to a rich text link field.
private static string UploadAttachment(
string attachmentString, string fileName, string checkInComment)
{
   InfoPathAttachmentDecoder decoder =
      new InfoPathAttachmentDecoder(attachmentString);

   string[] filearr = decoder.Filename.Split('.');
   string fullFileName =
      fileName + "." + filearr[filearr.Length-1];

   using (SPSite objSite = new SPSite("http://mysite"))
   {
      SPUserToken sysToken = objSite.SystemAccount.UserToken;
      using (SPSite purchSite =
         new SPSite("http://mysite/purchasing", sysToken))

      using (SPWeb objWeb = purchSite.OpenWeb())
         {
            SPFolder myLibrary = objWeb.Folders["Quotes"];
            objWeb.AllowUnsafeUpdates = true;

            myLibrary.Files.Add(fullFileName,
               decoder.DecodedAttachment,
               true,
               checkInComment,
               false);
         }
      }
   return fullFileName;
}

Open in new window

0
 

Author Closing Comment

by:RichShare
ID: 33702721
Thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question