Solved

Attaching files to a Sharepoint Library

Posted on 2010-08-23
4
577 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
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now