0

I am trying to upload an image on google drive using webapi. I copied the following chunk from Google drive doc but I am getting an error. Here is the code:

            var clientSecret = ConfigurationManager.AppSettings["GoogleDriveClientSecret"];
            var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret },
            scopes, Environment.UserName, CancellationToken.None).Result;
            var service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credential });

            var folderId = "0B2bBiMQICgHCMlp6OUxuSHNaZFU";
            var fileMetadata = new File()
            {
                Name = "photo.jpg",
                Parents = new List<string>
    {
        folderId
    }
            };
            FilesResource.CreateMediaUpload request;
            using (var stream = new System.IO.FileStream("files/photo.jpg",
                System.IO.FileMode.Open))
            {

                request = service.Files.Create(
                    fileMetadata, stream, "image/jpeg");
                request.Fields = "id";
                request.Upload();
            }
            var file = request.ResponseBody;

Now I am getting 2 errors in this code. First "Cannot resolve symbol Upload" at request.Upload() and second "Cannot resolve symbol ResponseBody" at request.ResponseBody

Any help?

diamond421
  • 137
  • 1
  • 2
  • 12

1 Answers1

0

You may refer with this related thread. The adding the attribute Inherits="Library.Account.RootVerifyUsers". Based from this reference, Visual Studio can often get confused about things like this. It is recommended to close Visual Studio and reopen it. Also, closing all open instances of VS may be required.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59