您无法将内容上载到application/vnd.google-apps.folder类型的文件中
本文关键字:folder google-apps vnd 类型 文件 application 上载 | 更新日期: 2023-09-27 18:24:18
我想在谷歌驱动器中添加新文件夹我使用这个代码:
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = "title";
body.Description = "description";
body.MimeType = "application/vnd.google-apps.folder";
byte[] byteArray = Encoding.ASCII.GetBytes(content);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
Google.Apis.Drive.v2.FilesResource.InsertMediaUpload request =
service.Files.Insert(body, stream, mimeType);
Google.Apis.Drive.v2.Data.File parentFolder = request.Upload();
符合代码:request.Upload()
我收到此错误:您无法将内容上传到application/vnd.google apps.folder
问题出在这条线上
Google.Apis.Drive.v2.FilesResource.InsertMediaUpload request =
service.Files.Insert(body, stream, mimeType);
你应该做一个简单的插入。通过调用InsertMediaUpload,您告诉驱动器您正试图将一些内容上传到Folder实体中,这当然毫无意义。