【发布时间】:2019-11-16 21:41:50
【问题描述】:
如何在 java 中使用 Google Drive v3 设置文件的应用属性?
参考资料说:“files.update with {'appProperties':{'key':'value'}}”,但我不明白如何将其应用于我的 java 代码。
我尝试过类似的东西
file = service.files().create(body).setFields("id").execute();
Map<String, String> properties = new HashMap<>();
properties.put(DEVICE_ID_KEY, deviceId);
file.setAppProperties(properties);
service.files().update(file.getId(), file).setFields("appProperties").execute();
但随后我收到“资源主体包含不可直接写入的字段”的错误消息。
并获取数据:
File fileProperty = service.files().get(sFileId).setFields("appProperties").execute();
那么如何设置和获取文件的属性呢? 谢谢! :)
编辑 我试过了
file = service.files().create(body).setFields("id").execute();
Map<String, String> properties = new HashMap<>();
properties.put(DEVICE_ID_KEY, deviceId);
file.setAppProperties(properties);
service.files().update(file.getId(), file).execute();
但我仍然收到相同的错误消息。
【问题讨论】:
标签: java google-drive-api