I'm using following code through the Microsoft Graph API dot.net sdk
using (Stream fileStream = file.InputStream)
{
DriveItem uploadedFile = await graphClient
.Drives[DRIVE_ID]
.Root.ItemWithPath($"{root}{relative}{file.FileName}")
.Content.Request()
.PutAsync<DriveItem>(fileStream);
}
to upload a simple file to OneDrive. Is it possible to prevent the file upload if the file already exists?
Update
The Microsoft Graph Documentation has been updated here a snippet from it:
Request body
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createuploadsession
No request body is required. However, you can specify a request body to provide additional data about the file being uploaded. For example, to control the behavior if the filename is already taken, you can specify the conflict behavior property in the body of the request.
{
"item": {
"@microsoft.graph.conflictBehavior": "rename"
}
}