上传文件到Google云端硬盘中的指定文件夹 [英] Upload Files to specified folder in Google Drive
本文介绍了上传文件到Google云端硬盘中的指定文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在将文件上传到Google云端硬盘中的现有文件夹时遇到问题。它一直告诉我xxx不存在。
I am having a problem on uploading files to an existing folder in google drive. It keeps telling me "xxx" does not exist.
String folderId = "Storage";
ChildReference newChild = new ChildReference();
newChild.setId(fileContent.getName());
drive.children().insert(folderId, newChild).execute();
请参阅 https://developers.google.com/drive/v2/reference/children/insert
推荐答案
是的,终于我可以上传我的文件整个目录到谷歌驱动器中的特定文件夹,只是因为无与伦比的folderid。
Yea, finally i can upload my whole directory of file to specific folder in google drive simply because of unmatched folderid.
我
String folderId = "0BwI6rRcqw8ZURlpleEVsRUhod0U";
File fileContent = new java.io.File(Environment.getExternalStorageDirectory() + "/DCIM/Camera/" + Files[count].getName());
FileContent mediaContent = new FileContent("image/jpeg", fileContent);
com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File();
body.setTitle(fileContent.getName());
body.setMimeType("image/jpeg");
body.setParents(Arrays.asList(new ParentReference().setId(folderId)));
com.google.api.services.drive.model.File file = drive.files().insert(body, mediaContent).execute();
这篇关于上传文件到Google云端硬盘中的指定文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文