4

i am developing a application for uploading file in Google drive using drive API.I am able to upload image successfully.but my problem is, when i cancel uploading it is not cancelled.I am uaing 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);

Following code is written on cancel botton click event

 ctsUpload.Cancel();
Abbas
  • 14,186
  • 6
  • 41
  • 72
Dev
  • 59
  • 6
  • Is it taking a long time to cancel or not cancelling at all? – Neil Turner Mar 30 '14 at 15:29
  • I don't know how it can be done in Drive-sdk, however I have implemented file uploading to google drive with cancel successfully using HttpWebRequest. If you are ok with that then I can post the solution using HttpWebRequest – Shivangi Gupta May 05 '14 at 08:52
  • may be you can try closing the stream "strm" too. If that helps – vCillusion Jul 16 '14 at 06:27

1 Answers1

0

Based on the following answer (Google drive SDK: Cancel upload) seems google has still this issue "unresolved".

In case of need axe found a solution.

afnpires
  • 601
  • 1
  • 8
  • 24