tl; dr : 빈 폴더를 Google 드라이브에 업로드 할 수 없습니다. Google API가 명확하지 않으며 도움이 필요합니다.폴더 만 Google 드라이브에 업로드하는 방법
Google 드라이브에 빈 폴더를 업로드 할 수있는 프로그램을 만들려고합니다. 폴더 작업을 위해 Google 드라이브 API를 살펴 봤는데 분명하지 않아서 사람들이 명확한 대답을 줄 수 있다면 감사하게 생각합니다!
파일 업로드를 위해 Google에서 소스 코드를 전환하려고했습니다. 즉, body.mimeType = "application/vnd.google-apps.folder"; 등등. 폴더를 byteArray로 변환 할 수 없기 때문에 UnauthorizedAccessException 오류가 발생합니다.
저는 C#에 대한 지식이별로 없으므로이 문제를 해결하는 방법을 모르겠습니다. 코드 스 니펫을 포함시켜 코드를 어디에 넣을 지 시각화 할 수 있다면 좋을 것입니다.
코드 :
Google.Apis.Drive.v2.Data.File folder = new Google.Apis.Drive.v2.Data.File();
folder.Title = My Folder;
folder.Description = desc.;
folder.MimeType = applicationvnd.google-apps.folder;
//Tried^that, didn't work
FilesResource.InsertMediaUpload request = service.Files.Insert(folder).Fetch();
Google.Apis.Drive.v2.Data.File file = service.Files.Insert(folder).Fetch();
File file = service.Files.Insert(folder).Fetch();
//Again, tried those but that didn't work either
File body = new File();
body.Title = "Document";
body.Description = "A test folder";
body.MimeType = "application/vnd.google-apps.folder";
byte[] byteArray = System.IO.File.ReadAllBytes("Folder");
//I know this doesn't work but had to try anyways
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "application/vnd.google-apps.folder");
request.Upload();
File file = request.ResponseBody;
Console.WriteLine(File id + file.Id);
나는 그게 내가 무엇을 시도했다 대부분에 대한 생각, 각각 작동하지 않았다. 내가 시도한 다른 것들이 있었지만 그 이후로 코드를 지우고 다시 작동하지 않기 때문에 다시 찾지 못했습니다.
감사합니다.
일부 코드보기 ... – Matt
[Google 드라이브에서 폴더를 만드는 방법 C# net api를 사용하는 방법] (http://stackoverflow.com/questions/10715962/how-to-create-folder-in-google -drive-using-c-sharp-net-api) – mason
@mason 나는 이미 그 링크에 대한 해답을 시도해 봤으며 거기에 주석이 달린 것처럼 .Fetch()도 나를 위해 작동하지 않는다. – Noob