GDrvAPIOp.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:media_information_service 作者:
private static void auxRetrieveAllFiles(List<String> lis,String auth, String link, String parents) throws IOException, UnirestException {
    HttpResponse<JsonNode> jsonResponse = Unirest.get(link).header("Authorization","Bearer "+auth).asJson();
    JSONObject jsonObject = new JSONObject(jsonResponse.getBody());
    JSONArray array = jsonObject.getJSONArray("array");
    for (int j=0;j<array.length();j++){
        JSONArray jarray=array.getJSONObject(j).getJSONArray("items");
        for(int i = 0; i < jarray.length(); i++)
        {
            if(jarray.getJSONObject(i).has("mimeType") && !jarray.getJSONObject(i).get("mimeType").equals("application/vnd.google-apps.folder")){
                String name= jarray.getJSONObject(i).getString("title");
                lis.add(jarray.getJSONObject(i).getString("title"));
            }
            else {
                if(jarray.getJSONObject(i).has("id")){
                    auxRetrieveAllFiles(lis,auth,"https://www.googleapis.com/drive/v2/files?includeTeamDriveItems=false&pageSize=500&q='"+jarray.getJSONObject(i).get("id")+"'%20in%20parents"+"&key="+ MISConfig.getGoogle_api(),parents);
                }
            }
        }
        if(array.getJSONObject(j).has("nextLink")){
            String next=array.getJSONObject(j).getString("nextLink");
            auxRetrieveAllFiles(lis,auth,next,parents);
        }
    }


}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号