4
I am sending file to Google Drive by their API. The request.Upload();
is lingering with no return. How do I make progress? It can be with a for
even without a graphical user interface.
Shipping method:
public static File UploadFile(DriveService _service, string _uploadFile, string _parent)
{
if (System.IO.File.Exists(_uploadFile))
{
File body = new File();
body.Title = System.IO.Path.GetFileName(_uploadFile);
body.Description = "Teste";
body.MimeType = GetMimeType(_uploadFile);
body.Parents = new List<ParentReference>() { new ParentReference() { Id = _parent } };
// monta os bytes
byte[] byteArray = System.IO.File.ReadAllBytes(_uploadFile);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
try
{
FilesResource.InsertMediaUpload request = _service.Files.Insert(body, stream, body.MimeType);
request.Upload();
return request.ResponseBody;
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
}
else
{
Console.WriteLine("File does not exist: " + _uploadFile);
return null;
}
}
What is the application environment? WPF? Web?
– Leonel Sanches da Silva
Windows Forms...
– War Lock
@Gypsy Rhyrrisonmendez can help me?
– War Lock