Skip to content

Instantly share code, notes, and snippets.

@chakkaradeep
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chakkaradeep/b8895ac7ece58471ad5c to your computer and use it in GitHub Desktop.
Save chakkaradeep/b8895ac7ece58471ad5c to your computer and use it in GitHub Desktop.
Office 365 API My Files - Create File
public static async Task<MyFile> Create(string strFileName, Stream streamFileContent)
{
//MyFile is the business object
MyFile myFile = null;
//add the file to OneDrive
//file name will be the full file name along with the extension
IFile file = await _spFilesClient.Files.AddAsync(strFileName, true, streamFileContent);
if (file != null)
{
//creae the business object
myFile = new MyFile();
myFile.Id = file.Id;
myFile.Name = file.Name;
myFile.ContentStream = streamFileContent;
}
//return the business object
return myFile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment