2012-12-16 168 views

回答

2

folderId是文件夾對象,而不是好聽的名字,如「存儲」的唯一標識符。您可以使用files().list() API call檢索文件夾的ID,可能使用q屬性根據需要過濾返回的結果。

+0

感謝Jay Lee的幫助指引。 – user1884888

3

是的,最後我可以上傳我的文件整個目錄到谷歌驅動器中的特定文件夾,只是因爲無與倫比的folderid。

我已經在下面的代碼中使用setParents函數成功了。

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(); 
+0

@很好的答案。感謝您的服務 –

+1

你從哪裏得到這個folderID來自????? – Josh

相關問題