我正在尝试使用webapi在Google云端硬盘上传图像。我从谷歌驱动器doc复制了以下块,但是我收到了一个错误。 这是代码:
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;
现在我在这段代码中遇到2个错误。首先&#34;无法解析符号上传&#34; at request.Upload()和second&#34;无法解析符号ResponseBody&#34; at request.ResponseBody
任何帮助?
答案 0 :(得分:0)
您可以参考此related thread。添加属性Inherits="Library.Account.RootVerifyUsers"
。基于此reference,Visual Studio经常会对此类事情感到困惑。建议关闭Visual Studio并重新打开它。此外,可能需要关闭VS的所有打开实例。