Skip to content

Instantly share code, notes, and snippets.

View garima2510's full-sized avatar

Garima Agrawal garima2510

View GitHub Profile
@garima2510
garima2510 / uploadfilestream.cs
Last active August 29, 2015 14:07
O365 - Upload Large File Without File Stream
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext, SPHostUrl);
using (var clientContext = spContext.CreateUserClientContextForSPAppWeb())
{
if (clientContext != null)
{
FileCreationInformation newFile = new FileCreationInformation();
//here file is the selected file. In this case of type HttpPostedFileBase
newFile.ContentStream = file.InputStream;
@garima2510
garima2510 / uploadfilelarge.cs
Created June 30, 2014 05:24
O365 - CSOM upload large files
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext, SPHostUrl);
using (var clientContext = spContext.CreateUserClientContextForSPAppWeb())
{
if (clientContext != null)
{
//file is uploaded file. Could be read from Request.Files
using (FileStream fs = new FileStream(file.FileName, FileMode.Open))
{
//code for file size > 2MB. tested upto 50MB
@garima2510
garima2510 / uploadfile.cs
Last active August 29, 2015 14:03
O365 - CSOM upload 2MB files
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext, SPHostUrl);
using (var clientContext = spContext.CreateUserClientContextForSPAppWeb())
{
if (clientContext != null)
{
//code for file size < 2MB
//file is the input which we uploaded. It can be taken from Request.Files
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(file.FileName);
@garima2510
garima2510 / App.css
Last active December 28, 2015 20:39
Demo of Knockout.js with SharePoint 2013 - Removing Items
/* Place custom styles below */
.tableStyle {
border-collapse:collapse;
border: 1px solid black;
text-align:center;
width:50%;
padding:15px;
}
@garima2510
garima2510 / App.css
Last active December 28, 2015 18:09
Demo of Knockout.js with Sharepoint 2013 - Adding Items
.tableStyle {
border-collapse:collapse;
border: 1px solid black;
text-align:center;
width:50%;
padding:15px;
}
.messages {
display:none;
@garima2510
garima2510 / App.css
Last active January 6, 2017 14:49
Demo of Knockout.js with Sharepoint 2013
.tableStyle {
border-collapse:collapse;
border: 1px solid black;
text-align:center;
width:50%;
padding:15px;
}