how to create empty folder on google drive?

2020-07-18 06:15发布

问题:

I am trying to create empty folder for my android app..

File body = new File();

body.setTitle("title");

java.io.File fileContent = new java.io.File("title");

FileContent mediaContent = new FileContent("application/vnd.google-apps.folder", fileContent);

File file = service.files().insert(body, mediaContent).execute();

This doesnt seem to work.....

Getting exception:

java.io.FileNotFoundException:/title open failed ENOENT ( no such file or directory)

Caused by: libcore.io.ErrnoException: open failed: ENOENT (no such file or directory)

回答1:

Solved...

File body = new File();
body.setTitle("title");
body.setMimeType("application/vnd.google-apps.folder");
File file = service.files().insert(body).execute();

It will create folder named title in google drive.



回答2:

hmmm, I get "Insufficient permission [403]" error