Information Services
asked on
How do I push pdfs to a folder in sharepoint online?
We are wanting to push our direct deposit remittance documents to a folder on SharePoint Online for our employees.
Is it possible to connect to SharePoint in C# and transfer those files to a particular folder in SharePoint?
Is it possible to connect to SharePoint in C# and transfer those files to a particular folder in SharePoint?
ASKER
So Shaun, would the PDFs be part of a list or can I send them as documents within a document library?
You can do both but I recommend document library
ASKER
So do I create a document library and then just move the objects into it?
Create document library, use C# to read documents as a byte array and submit to the document library via CSOM
public void UploadDocument(string siteURL, string documentListName,
string documentListURL, string documentName,
byte[] documentStream)
{
using (ClientContext clientContext = new ClientContext(siteURL))
{
//Get Document List
List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);
var fileCreationInformation = new FileCreationInformation();
//Assign to content byte[] i.e. documentStream
fileCreationInformation.Content = documentStream;
//Allow owerwrite of document
fileCreationInformation.Overwrite = true;
//Upload URL
fileCreationInformation.Url = siteURL + documentListURL + documentName;
Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(
fileCreationInformation);
//Update the metadata for a field having name "DocType"
uploadFile.ListItemAllFields["DocType"] = "Favourites";
uploadFile.ListItemAllFields.Update();
clientContext.ExecuteQuery();
}
}
https://stackoverflow.com/questions/9847935/upload-a-document-to-a-sharepoint-list-from-client-side-object-model
ASKER
Thanks Shaun. Give me a little bit to try things and if all goes as planned, I should be able to award the points and close the question.
ASKER
Shaun,
I'm having trouble locating the Microsoft.SharePoint dlll to reference in my project. Any tips on finding it?
I'm having trouble locating the Microsoft.SharePoint dlll to reference in my project. Any tips on finding it?
Yes, for that DLL you need to have SharePoint installed on your dev computer. When I do SharePoint dev, I spin up an SPS cluster in Azure with Visual Studio.
ASKER
Shaun,
I hate to be so dense, but do you know of an article that shows how to do that?
I hate to be so dense, but do you know of an article that shows how to do that?
No problem. Here is an article for 2016 but in it, there is a link to 2013 if you prefer
https://cann0nf0dder.wordpress.com/2016/08/30/building-sharepoint-2016-development-environment-part-1-introduction/
https://cann0nf0dder.wordpress.com/2016/08/30/building-sharepoint-2016-development-environment-part-1-introduction/
ASKER
Shaun,
We only have a SharePoint presence online. Is it possible to connect to that instance without a local installation?
We only have a SharePoint presence online. Is it possible to connect to that instance without a local installation?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code