/// <summary> /// Initiates a resumable upload session to OneDrive. It doesn't perform the actual upload yet. /// </summary> /// <param name="oneDriveUrl">Complete URL to call to create the resumable upload session</param> /// <returns>OneDriveUploadSession instance containing the details where to upload the content to</returns> protected async Task <OneDriveUploadSession> CreateResumableUploadSessionInternal(string oneDriveUrl) { // Construct the OneDriveUploadSessionItemContainer entity with the upload details // Add the conflictbehavior header to always overwrite the file if it already exists on OneDrive var uploadItemContainer = new OneDriveUploadSessionItemContainer { Item = new OneDriveUploadSessionItem { FilenameConflictBehavior = NameConflictBehavior.Replace } }; // Call the OneDrive webservice var result = await SendMessageReturnOneDriveItem <OneDriveUploadSession>(uploadItemContainer, HttpMethod.Post, oneDriveUrl, HttpStatusCode.OK); return(result); }
/// <summary> /// Initiates a resumable upload session to OneDrive. It doesn't perform the actual upload yet. /// </summary> /// <param name="fileName">Filename to store the uploaded content under</param> /// <param name="oneDriveItem">OneDriveItem container in which the file should be uploaded</param> /// <returns>OneDriveUploadSession instance containing the details where to upload the content to</returns> protected override async Task <OneDriveUploadSession> CreateResumableUploadSession(string fileName, OneDriveItem oneDriveItem) { // Construct the complete URL to call var completeUrl = string.Concat(OneDriveApiBaseUrl, "drive/items/", oneDriveItem.Id, ":/", fileName, ":/createUploadSession"); // Construct the OneDriveUploadSessionItemContainer entity with the upload details // Add the conflictbehavior header to always overwrite the file if it already exists on OneDrive var uploadItemContainer = new OneDriveUploadSessionItemContainer { Item = new OneDriveUploadSessionItem { FilenameConflictBehavior = NameConflictBehavior.Replace } }; // Call the OneDrive webservice var result = await SendMessageReturnOneDriveItem <OneDriveUploadSession>(uploadItemContainer, HttpMethod.Post, completeUrl, HttpStatusCode.OK); return(result); }