【发布时间】:2015-08-27 02:24:45
【问题描述】:
我应该遵循哪些规则来设置文件的自定义 ID?我尝试了简短的“12345”、“abcde”、44 个字符的字母数字字符串、UUID.randomUUID().toString()(带/不带破折号)-所有尝试都返回“提供的文件 ID 不可用”。我找不到任何书面要求。代码:
Drive drive = new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credentials).build();
FileContent mediaContent = new FileContent("image/png", tempFile);
File body = new File();
body.setId(...);
body.setTitle(...);
body.setMimeType("image/png");
File result = drive.files().insert(body, mediaContent).execute();
回应:
400 Bad Request
{
"code": 400,
"errors":
[{
"domain": "global",
"location": "file.id",
"locationType": "other",
"message": "The provided file ID is not usable",
"reason": "invalid"
}],
"message": "The provided file ID is not usable"
}
当我不尝试设置 ID 时,相同的代码会正确地将我的文件上传到云端硬盘。
【问题讨论】:
标签: android google-api google-drive-api