I am not able to use this code to upload large file to share point as mentioned in the documentation here:
https://learn.microsoft.com/en-us/graph/sdks/large-file-upload?tabs=java
This returns an error as below:
om.microsoft.kiota.ApiException: generalException
at com.microsoft.kiota.ApiExceptionBuilder.withMessage(ApiExceptionBuilder.java:45)
at com.microsoft.graph.core.requests.upload.UploadResponseHandler.handleResponse(UploadResponseHandler.java:62)
at com.microsoft.graph.core.requests.upload.UploadSliceRequestBuilder.put(UploadSliceRequestBuilder.java:69)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.uploadSlice(LargeFileUploadTask.java:207)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:131)
I am using the same code as mentioned in the documentation and the only change is the path of the file in share point. The variable destinationWithDate is some folder structure I need e.g. 2024/July/FolderA/FolderB/file.txt
UploadSession uploadSession = graphServiceClient.drives()
.byDriveId(drive.getId())
.items()
.byDriveItemId("root:/"+destinationWithDate+":")
.createUploadSession()
.post(uploadSessionRequest);
The code fails at upload and the error returned does not tell much about it.
UploadResult<DriveItem> uploadResult = largeFileUploadTask.upload(maxAttempts, callback);
For the smaller files this code works perfectly for me so I am assuming the destinationWithDate variable is not an issue:
graphServiceClient.drives().byDriveId(drive.getId()).items().byDriveItemId("root:/" + destinationWithDate + ":").content().put(fileStream);
I am using version 6.4.0 of graph api. I tried a couple of older versions too but it did not help. Please help me with the larger files upload error. I could not find anything helpful so far related to larger file upload using Graph API and Java.