Pratik
Pratik

Reputation: 125

How to remove partially uploaded file to Onedrive using Microsoft graph API

A file was partially uploaded to Onedrive using Microsoft graph API, because of some internet issue. Now the uploaded file is incomplete and has some temporary extension. The file size is more than 10MB, and only few MBs has been uploaded.

the request look like following:

POST /drive/root:/{item-path}:/createUploadSession

My question is how to get rid of such file using graph API.

Is there any way to provide such information along with the request to remove such file if it fails to upload completely after some time.

Upvotes: 1

Views: 1773

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

Yes. You can send a DELETE to the upload session URL.

From the documentation:

To cancel an upload session send a DELETE request to the upload URL. This cleans up the temporary file holding the data previously uploaded. This should be used in scenarios where the upload is aborted, for example, if the user cancels the transfer.

Temporary files and their accompanying upload session are automatically cleaned up after the expirationDateTime has passed. Temporary files may not be deleted immediately after the expiration time has elapsed.

Upvotes: 1

Related Questions