diff --git a/Api/OneDriveGraphApi.cs b/Api/OneDriveGraphApi.cs index dedf1df..a710e83 100644 --- a/Api/OneDriveGraphApi.cs +++ b/Api/OneDriveGraphApi.cs @@ -2468,9 +2468,6 @@ protected virtual async Task UploadFileViaResumableUploadInternal( throw new ArgumentNullException("oneDriveUploadSession"); } - // Get an access token to perform the request to OneDrive - var accessToken = await GetAccessToken(); - // Amount of bytes succesfully sent long totalBytesSent = 0; @@ -2489,8 +2486,10 @@ protected virtual async Task UploadFileViaResumableUploadInternal( // Defines a buffer which will be filled with bytes from the original file and then sent off to the OneDrive webservice var fragmentBuffer = new byte[fragmentSizeInBytes ?? ResumableUploadChunkSizeInBytes]; - // Create an HTTPClient instance to communicate with the REST API of OneDrive to perform the upload - using (var client = CreateHttpClient(accessToken.AccessToken)) + // Create an HTTPClient instance to communicate with the upload session's URL. Note that no bearer token is set here: + // oneDriveUploadSession.UploadUrl is a pre-authenticated, opaque URL with its own embedded access token, and Microsoft + // Graph rejects (some backends silently reject, others error) fragment uploads that also carry an Authorization header. + using (var client = CreateHttpClient()) { // Keep looping through the source file length until we've sent all bytes to the OneDrive webservice while (currentPosition < fileStream.Length) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9b9686..5b17ca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project are documented in this file. +## [3.0.2.0] + +- Fixed a potential issue with larger file uploads [#49](https://github.com/KoenZomers/OneDriveAPI/pull/49). Thanks YasarF! + ## [3.0.1.0] ### Fixed