How do I cancel a download in the Google Drive API?

I am developing an application to upload a file to Google Drive using the API Drive. I can upload the image successfully. But my problem is that when I cancel the download, it does not cancel. I am reading the following code:

Google.Apis.Drive.v2.Data.File image = new Google.Apis.Drive.v2.Data.File();
//set the title of file
image.Title = fileName;
//set Mime Type of file
image.MimeType = "image/jpeg";
//set the stream position 0 because stream is readed already
strm.Position = 0;
//create a request for insert a file
System.Threading.CancellationTokenSource ctsUpload = new CancellationTokenSource();           
FilesResource.InsertMediaUpload request = App.GoogleDriveClient.Files.Insert(image, strm, "image/jpeg");
request.ChunkSize = 512 * 1024; 
request.ProgressChanged += request_ProgressChanged;
//visible the uploading progress            
//upload file 
request.UploadAsync(ctsUpload.Token);

The following code is written to cancel a pop-click event

 ctsUpload.Cancel();
+4
source share
1 answer

Based on the following answer ( Google Drive SDK: Cancel Download ), it seems that google still has this "unresolved" problem.

If necessary, ax found a solution.

0
source

Source: https://habr.com/ru/post/1525568/


All Articles