How to cancel file upload request with Google Drive SDK
?
I'm creating .NET 4 task that calls
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, body.MimeType);
request.Upload();
I can't use cancellation token here to cancel my task and I can't find any method for cancelling request too. How should I stop the uploading process?\
update
Hello? Is there anybody?
Google support is "awesome". I think even on happy housewives club forum
I would get at least one answer.
I already know that this is not possible and I've added cancellation support to upload function myself, but guys, if you provide support you need to answer from time to time. This is not the first long time waiting for response from Google support.
Here you say that you support Google Drive SDK
on Stack Overflow. You definitely need to improve your responsiveness.
For the rest of people who may be interested in.
I changed project to use .NET framework 4.0 and in file Src\GoogleApis\Apis\Upload\ResumableUpload.cs
added overload CancellationToken token
parameter to the Upload
function.
do
{
token.ThrowIfCancellationRequested(); // <----------------------
bytesSent += SendChunk(contentStream, url, bytesSent);
UpdateProgress(UploadStatus.Uploading, bytesSent);
} while (bytesSent < contentStream.Length);
Then added marked line to the upload loop.
To avoid having failed tests you may also overload Upload
function like this
public void Upload()
{
Upload(new CancellationTokenSource().Token);
}
That's it.