When downoading from sharepoint with buffer size always getting maximum 8K buffer and not as we asked
Describe the bug
When downloading file from sharepoint using graph api and set the buffer size to be downloaded only 8K ( maximum) is fetched ) instread of the given buffer size. InputStream inputStream = graphServiceClient.drives().byDriveId(driveId).items().byDriveItemId(getDriveItemIdFromRootPath(filePath)).content().get(); byte[] buf = new byte[cloudPartSizeWhenDownloadingToLocal]; int bytesRead; while ((bytesRead = srcInputStream.read(buf)) != -1) { byresRead is always maximum 8K and not per demand }
Expected behavior
The bytess returned from this method should aline with the request.
How to reproduce
see above
SDK Version
6.25.1
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Hi @Ndiritu Any updates? Thanks, Itay
Hi @ihudedi
To control the number of bytes returned you'd need to download the Drive Item first & pass a Range header to the download URL - docs. The .../content endpoint doesn't support partial downloads
Lmk if you face any more issues.
Hi @Ndiritu I don't want partial download. SO what you tell me that by default you download only 8K each call? And how do I download range content via java? Thanks, Itay
@ihudedi /content should return the entire item. Do you mean that the API is only returning 8Kb of a larger file?
Are you able to validate this using Graph Explorer or a raw HTTP call without the SDK?
You can use the requestConfiguration object to pass custom headers e.g. Range for the partial download
Hi @Ndiritu When using content we get InputStream object. Trying to read X bytes always return 8K bytes maximum. I will try the range header to see I I get only the range Thanks, Itay
Hi @Ndiritu Issue was resolved. Thanks, Itay
Great to hear @ihudedi Are you able to share what the root cause was for future reference by others?
Hi @Ndiritu The inputStream.read(buf)) always bring only max 8K bytes I used in parallel and fetch the stream in ranges. Still the read should fetch all the bytes in the buffer not only 8K Thanks, Itay