Skip to content

Commit 0023327

Browse files
authored
Merge pull request #49 from YasharF/master
fix: don't send auth header for resumable upload PUT requests
2 parents 0faff02 + 8fa68a3 commit 0023327

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎Api/OneDriveGraphApi.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,9 +2468,6 @@ protected virtual async Task<OneDriveItem> UploadFileViaResumableUploadInternal(
24682468
throw new ArgumentNullException("oneDriveUploadSession");
24692469
}
24702470

2471-
// Get an access token to perform the request to OneDrive
2472-
var accessToken = await GetAccessToken();
2473-
24742471
// Amount of bytes succesfully sent
24752472
long totalBytesSent = 0;
24762473

@@ -2489,8 +2486,10 @@ protected virtual async Task<OneDriveItem> UploadFileViaResumableUploadInternal(
24892486
// Defines a buffer which will be filled with bytes from the original file and then sent off to the OneDrive webservice
24902487
var fragmentBuffer = new byte[fragmentSizeInBytes ?? ResumableUploadChunkSizeInBytes];
24912488

2492-
// Create an HTTPClient instance to communicate with the REST API of OneDrive to perform the upload
2493-
using (var client = CreateHttpClient(accessToken.AccessToken))
2489+
// Create an HTTPClient instance to communicate with the upload session's URL. Note that no bearer token is set here:
2490+
// oneDriveUploadSession.UploadUrl is a pre-authenticated, opaque URL with its own embedded access token, and Microsoft
2491+
// Graph rejects (some backends silently reject, others error) fragment uploads that also carry an Authorization header.
2492+
using (var client = CreateHttpClient())
24942493
{
24952494
// Keep looping through the source file length until we've sent all bytes to the OneDrive webservice
24962495
while (currentPosition < fileStream.Length)

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project are documented in this file.
44

5+
## [3.0.2.0]
6+
7+
- Fixed a potential issue with larger file uploads [#49](https://github.com/KoenZomers/OneDriveAPI/pull/49). Thanks YasarF!
8+
59
## [3.0.1.0]
610

711
### Fixed

0 commit comments

Comments
 (0)