尝试上传到我的驱动器时获取request.ResponseBody = null。 我发现以下异常'值不能为null。参数名称:baseUri'
这里是代码
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = System.IO.Path.GetFileName(uploadFile);
body.Description = "File uploaded";
body.MimeType = GetMimeType(uploadFile);
body.Editable = true;
body.Shared = false;
body.Parents = new List<ParentReference>() { new ParentReference() { Id = parentID } };
var x = service.HttpClient.GetByteArrayAsync(uploadFile);
byte[] arrBytes = x.Result;
System.IO.MemoryStream stream = new System.IO.MemoryStream(arrBytes);
try
{
if (arrBytes.Length > 0)
{
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, GetMimeType(uploadFile));
request.Convert = true;
request.Upload();
return request.ResponseBody;
}
else
{
Console.WriteLine("File does not exist: " + uploadFile);
return null;
}
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
关于我失踪的任何想法?
修改
文件现在上传到驱动器,我删除了API部分中的任何Referrers。 但响应仍为空
答案 0 :(得分:0)
我遇到了同样的问题 - 通过nuget更新后 - Zlib.Portable更新到版本1.11.0.0,而Google使用版本1.10.0.0 -
检查您的参考版本!