- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
要将文件上传到云端硬盘中的特定文件夹,我知道我必须在以下方法中设置参数parentId:
File body = new File();
body.setParents(Arrays.asList(new ParentReference().setId(parentId)));
现在,有没有办法使用不同的参数?我的问题是,当我使用 Gson 解析器从 Drive 中的特定文件夹检索资源时,parentId 属性始终为 null。为什么会发生这种情况?上传的时候需要设置Id吗?如果我直接在drive.google.com 站点中创建文件夹会怎样?其他参数(例如 title 或 dateCreated)工作正常。
非常感谢。
编辑:我添加了一些代码来显示发生了什么。
MyJson.java
@SerializedName("parentId")
private String parentId;
@SerializedName("createdDate")
private String createdDate;
public final String getDateCreated(){
return this.createdDate;
}
public final String getParentId(){
return this.parentId;
}
Main.java
public static String[] jsonParser(String jsonText){
Gson gson = new Gson();
JsonParser parser = new JsonParser();
JsonArray Jarray = parser.parse(jsonText).getAsJsonArray();
ArrayList<MyJson> lcs = new ArrayList<MyJson>();
StringBuilder sb = new StringBuilder();
//Please ignore this Stringbuilder is just for testing purposes
for(JsonElement obj : Jarray )
{
MyJson cse = gson.fromJson( obj , MyJson.class);
lcs.add(cse);
}
List<String> strings = new ArrayList<String>();
for(MyJson j: lcs){
strings.add(j.getTitle() );
sb.append(j.getParentId() + " " + j.getDateCreated());
}
System.out.println(sb.toString()); //Here it prints out null+date
String[] arr = strings.toArray(new String[strings.size()]);
//When I print this array shows the title perfectly
return arr;
}
这是我传递给上一个方法的文本资源。
[[{"alternateLink":"https://docs.google.com/folderview?id=0Byylok4NwwGOR2VTX1JOb1BnNDg&usp=drivesdk","appDataContents":false,"createdDate":"2013-07-25T06:17:20.228Z","editable":true,"etag":"\"RFvxxXV9yoZniidCHgcusodAlXI/MTM3NDczMzA0MDIyOA\"","iconLink":"https://ssl.gstatic.com/docs/doclist/images/icon_11_collection_list.png","id":"0Byylok4NwwGOR2VTX1JOb1BnNDg","kind":"drive#file","labels":{"hidden":false,"restricted":false,"starred":false,"trashed":false,"viewed":false},"lastModifyingUser":{"displayName":"Luis Manuel Lavieri","isAuthenticatedUser":true,"kind":"drive#user","permissionId":"13217068352953415214","picture":{"url":"https://lh3.googleusercontent.com/-yNHuP50oJzI/AAAAAAAAAAI/AAAAAAAAAIQ/Wv4lZdE3FyU/s64/photo.jpg"}},"lastModifyingUserName":"Luis Manuel Lavieri","mimeType":"application/vnd.google-apps.folder","modifiedDate":"2013-07-25T06:17:20.228Z","ownerNames":["Luis Manuel Lavieri"],"owners":[{"displayName":"Luis Manuel Lavieri","isAuthenticatedUser":true,"kind":"drive#user","permissionId":"13217068352953415214","picture":{"url":"https://lh3.googleusercontent.com/-yNHuP50oJzI/AAAAAAAAAAI/AAAAAAAAAIQ/Wv4lZdE3FyU/s64/photo.jpg"}}],"parents":[{"id":"0ACylok4NwwGOUk9PVA","isRoot":true,"kind":"drive#parentReference","parentLink":"https://www.googleapis.com/drive/v2/files/0ACylok4NwwGOUk9PVA","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGOR2VTX1JOb1BnNDg/parents/0ACylok4NwwGOUk9PVA"}],"quotaBytesUsed":"0","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGOR2VTX1JOb1BnNDg","shared":false,"title":"Web Design","userPermission":{"etag":"\"RFvxxXV9yoZniidCHgcusodAlXI/Rok55oKCdYb_mqyTjquQPLiUiIg\"","id":"me","kind":"drive#permission","role":"owner","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGOR2VTX1JOb1BnNDg/permissions/me","type":"user"},"writersCanShare":true}, {"alternateLink":"https://docs.google.com/folderview?id=0Byylok4NwwGORzhjODJPeVVUYXM&usp=drivesdk","appDataContents":false,"createdDate":"2013-07-25T06:17:10.835Z","editable":true,"etag":"\"RFvxxXV9yoZniidCHgcusodAlXI/MTM3NDczMzAzMDgzNQ\"","iconLink":"https://ssl.gstatic.com/docs/doclist/images/icon_11_collection_list.png","id":"0Byylok4NwwGORzhjODJPeVVUYXM","kind":"drive#file","labels":{"hidden":false,"restricted":false,"starred":false,"trashed":false,"viewed":false},"lastModifyingUser":{"displayName":"Luis Manuel Lavieri","isAuthenticatedUser":true,"kind":"drive#user","permissionId":"13217068352953415214","picture":{"url":"https://lh3.googleusercontent.com/-yNHuP50oJzI/AAAAAAAAAAI/AAAAAAAAAIQ/Wv4lZdE3FyU/s64/photo.jpg"}},"lastModifyingUserName":"Luis Manuel Lavieri","mimeType":"application/vnd.google-apps.folder","modifiedDate":"2013-07-25T06:17:10.835Z","ownerNames":["Luis Manuel Lavieri"],"owners":[{"displayName":"Luis Manuel Lavieri","isAuthenticatedUser":true,"kind":"drive#user","permissionId":"13217068352953415214","picture":{"url":"https://lh3.googleusercontent.com/-yNHuP50oJzI/AAAAAAAAAAI/AAAAAAAAAIQ/Wv4lZdE3FyU/s64/photo.jpg"}}],"parents":[{"id":"0ACylok4NwwGOUk9PVA","isRoot":true,"kind":"drive#parentReference","parentLink":"https://www.googleapis.com/drive/v2/files/0ACylok4NwwGOUk9PVA","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGORzhjODJPeVVUYXM/parents/0ACylok4NwwGOUk9PVA"}],"quotaBytesUsed":"0","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGORzhjODJPeVVUYXM","shared":false,"title":"Finance","userPermission":{"etag":"\"RFvxxXV9yoZniidCHgcusodAlXI/Hsb4mdHUJCfDZwXE6ivhuygOXig\"","id":"me","kind":"drive#permission","role":"owner","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGORzhjODJPeVVUYXM/permissions/me","type":"user"},"writersCanShare":true}, {"alternateLink":"https://docs.google.com/folderview?id=0Byylok4NwwGOa1E5Zng1dTVpZ0U&usp=drivesdk","appDataContents":false,"createdDate":"2013-07-25T06:17:00.482Z","editable":true,"etag":"\"RFvxxXV9yoZniidCHgcusodAlXI/MTM3NDczMzAyMDQ4Mg\"","iconLink":"https://ssl.gstatic.com/docs/doclist/images/icon_11_collection_list.png","id":"0Byylok4NwwGOa1E5Zng1dTVpZ0U","kind":"drive#file","labels":{"hidden":false,"restricted":false,"starred":false,"trashed":false,"viewed":false},"lastModifyingUser":{"displayName":"Luis Manuel Lavieri","isAuthenticatedUser":true,"kind":"drive#user","permissionId":"13217068352953415214","picture":{"url":"https://lh3.googleusercontent.com/-yNHuP50oJzI/AAAAAAAAAAI/AAAAAAAAAIQ/Wv4lZdE3FyU/s64/photo.jpg"}},"lastModifyingUserName":"Luis Manuel Lavieri","mimeType":"application/vnd.google-apps.folder","modifiedDate":"2013-07-25T06:17:00.482Z","ownerNames":["Luis Manuel Lavieri"],"owners":[{"displayName":"Luis Manuel Lavieri","isAuthenticatedUser":true,"kind":"drive#user","permissionId":"13217068352953415214","picture":{"url":"https://lh3.googleusercontent.com/-yNHuP50oJzI/AAAAAAAAAAI/AAAAAAAAAIQ/Wv4lZdE3FyU/s64/photo.jpg"}}],"parents":[{"id":"0ACylok4NwwGOUk9PVA","isRoot":true,"kind":"drive#parentReference","parentLink":"https://www.googleapis.com/drive/v2/files/0ACylok4NwwGOUk9PVA","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGOa1E5Zng1dTVpZ0U/parents/0ACylok4NwwGOUk9PVA"}],"quotaBytesUsed":"0","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGOa1E5Zng1dTVpZ0U","shared":false,"title":"Marketing","userPermission":{"etag":"\"RFvxxXV9yoZniidCHgcusodAlXI/1meV_djX_pEtNrpJb1GQPQAT5hw\"","id":"me","kind":"drive#permission","role":"owner","selfLink":"https://www.googleapis.com/drive/v2/files/0Byylok4NwwGOa1E5Zng1dTVpZ0U/permissions/me","type":"user"},"writersCanShare":true}]]
我知道那里有各种类型的id,而不是我正在寻找的(parentId,folderId),但是如果我想在“Web Design”文件夹中插入文件我该怎么办?我该如何设置这些 Id?我应该如何处理空值?
最佳答案
就像设置父对象一样,使用父对象列表,您应该以相同的方式读取它。
"parents": [
parents Resource
],
不是父 ID。
关于java - 在Java中插入没有parentId的Google Drive文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17868084/
我正在尝试将新的父项目和新的子项目保存到遗留数据库 我的数据很好,当我保存它时,它同时保存了父项和子项。但是 child 的 SillyNameParentId 始终为 0 我无法更改表结构,所以我必
如何在同一张表上设置父子关系? Id int, title string, ParentId int ---> this is refer to Id 最佳答案 您使用的是什么 ActiveReco
我有以下结构: MyClass { guid ID guid ParentID string Name } 我想创建一个数组,其中包含按照元素应在层次结构中显示的顺序排列的元素(例如,根据
MyClass由 ID 组成ParentID和 List作为Children 我有 MyClass 的列表像这样 ID ParentID 1 0 2 7 3 1 4 5 5 1
我需要一些帮助来构建一个查询,以便我过滤以下数据。 Table: MyTree Id ParentId Visible ===================== 1 null 0
我有一张这样的 table foo(id, parentId) -- there is a FK constraint from parentId to id 我需要删除一个项目及其所有 child
我有一个看似简单的任务,但我遇到的麻烦远比我愿意承认的要多。我有一个层次表,我需要查询和显示由父级和相关子级分组的结果。 我当前的 LINQ 查询: var quests = Questions.In
我有一个看似简单的任务,但我遇到的麻烦远比我愿意承认的要多。我有一个层次表,我需要查询和显示由父级和相关子级分组的结果。 我当前的 LINQ 查询: var quests = Questions.In
网站核心 reference谈谈你可以在Query中使用的一些属性,包括@@templatename、@@id和@@parentid等。 parentid 似乎不起作用 - /sitecore/con
我有以下两个数据库表: 新闻表: newsID, topic, categoryID 类别表: categoryID, title, parentID 我想获取 newsID、主题、主类别的标题,如果
//Set Parent ID for the rest of the Reports data sources this.ReportDataSources.ToList().ForEach(rds
每个父元素都应包含所有子类别的总数。如果解决方案将使用仅 Array 对象方法而不使用 while 循环,那将是非常好的。 这是基础结构的例子: const base = [ { id: 1, c
我会尽量解释清楚。这是我的查询.. SELECT * FROM mm_star_ratings s JOIN mm_posts p ON s.post_id = p.postid WHERE p.ty
我有一个类似 records(ID, ParentID) 的表,其中包含以下数据: ID ParentID 1 null 2 1 3 2 4 2 5 3
我有两个数组。两者都包含具有唯一 id 和 parentid 值的对象(给定的 id 只是示例,实际上它们是由 uuid 生成器生成的)。第一个是按照 parentid 不同于“parent”的对象位
这是表的示例结构: ID Name ParentID ----------------------- 1 Ancestor NULL 2 GrandFather
我有一个具有多层嵌套的层次结构树 JSON。当我尝试循环 JSON 以在 UI 中显示树结构时。我最终得到了循环冗余,因为父 ID 在不同级别上是相同的。我需要为parentID和ID添加唯一标识符,
给定一个平面级别的对象数组,根据 parent 和 id 属性嵌套它们的最有效和现代的方法是什么?顶层对象没有parentId,嵌套层数没有限制。 [{ id: 'OS:MacOS', typ
给定一个平面级别的对象数组,根据 parent 和 id 属性嵌套它们的最有效和现代的方法是什么?顶层对象没有parentId,嵌套层数没有限制。 [{ id: 'OS:MacOS', typ
我正在为我的应用程序编写一个 CMIS 接口(interface)。此接口(interface)返回 cmis:document作为 cmis:folder 的子对象的对象目的。这里是 a part
我是一名优秀的程序员,十分优秀!