Solved

Attaching files to a Sharepoint Library

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

742 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