Like explained in the documentation https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/tasks/LargeFileUploadTask.md , I try to cancel a large file upload with the following:
const options: OneDriveLargeFileUploadOptions = {
path: destinationDirectory,
fileName: stream.name,
conflictBehavior: 'rename',
rangeSize: 1024 * 1024
};
const fileObject = new FileUpload(
stream.content,
stream.name,
stream.content.size
);
const task = await OneDriveLargeFileUploadTask.createTaskWithFileObject(
client,
fileObject,
options
);
await task.upload();
// when needed:
task.cancel();
The cancel method generates a DELETE request on the url of the upload session but it returns 404 and the upload continues, and the file is created in my OneDrive directory.