【发布时间】:2022-07-07 16:47:00
【问题描述】:
我正在尝试使用来自 android 应用程序的 REST API 将本地文件上传到 Google Drive 中的指定文件夹,该文件正在根目录中上传,但未在指定文件夹中上传。 API 中没有错误。
使用以下 API: https://developers.google.com/drive/api/guides/manage-uploads#multipart
尝试通过以下方式在元数据中传递文件夹 ID:
1.
String[] arr = {parentFolderId};
jsonObject.put("parents", arr);
jsonObject.put("name", file.getName());
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("id", parentFolderId);
jsonArray.put(jsonObject1);
jsonObject.put("parents", jsonArray);
jsonObject.put("name", file.getName());
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(parentFolderId);
jsonObject.put("parents", arrayList);
jsonObject.put("name", file.getName());
“parents”参数不起作用,也尝试使用“addParents”参数。 请提出一种指定父文件夹 ID 的方法。
【问题讨论】:
-
以后你应该包含你从这些调用中得到的错误信息。
标签: java android google-api google-drive-api google-api-java-client