Documents
Download & upload files from/to SharePoint is simple
SharePoint is ECM (Enterprise Content Management) system and it's common to expect files being uploaded, downloaded, migrated, processes, and managed in a variety ways.
Gosip provides an easy way of dealing with SharePoint document listaries, files and folders.
Getting library object
Document library in SharePoint is almost the same as a List, but with intention of being a container for files.
// The recommended way of getting lists is by using their relative URIs
// can be a short form without full web relative URL prefix
list := sp.Web().GetList("MyLibrary")
// other common but less recommended way of getting a list is
// list := sp.Web().Lists().GetByTitle("My Library")Getting folder object
folder := sp.Web().GetFolder("MyLibrary/Folder01")Getting file object
file := sp.Web().GetFile("MyLibrary/Folder01/File01.txt")Adding new folder
// folderResp is a byte array read from response body with extra methods
folderResp, err := folder.Folders().Add("New Folder Name")
if err != nil {
log.Fatal(err)
}
fmt.Printf("New folder URL: %s\n", folderResp.Data().ServerRelativeURL)Deleting folders
Adding/uploading a file
Obviously, file content can be a result of reading a file from disk, e.g.:
For the large files it's better using AddChunked API, hovewer, it was not available in SharePoint 2013.
Downloading files
For a large files it's better getting file reader through:
Summary
Using Gosip you can concentrate on business logic and Go language aspects while processing documents actions in SharePoint seemlessly.
With use of IntelliSense and Fluent syntax other supported actions can be consumed based on a specific requirement.
Last updated
Was this helpful?
