【发布时间】:2021-02-03 12:12:56
【问题描述】:
我想从 Gdrive 下载文件。所以我使用的是驱动 API v3 (java)。
这里是代码 sn-p。
Drive.Files.Get request = driveService.files().get(fileId);
// Get the file metadata
File downloadFile = request.execute();
Long fileSize = downloadFile.getSize(); // always returns null.
OutputStream out = new FileOutputStream(fileName);
request.getMediaHttpDownloader().setProgressListener(
new DriveDownloadProgressListener(messageQueue));
request.executeMediaAndDownloadTo(out);
这里 downloadFile.getSize() 总是返回 null。 有没有办法从 MediaHttpDownloader 获取文件大小?
【问题讨论】:
-
这能回答你的问题吗? Google Drive: The file size is null
-
不。我已经检查过了。
-
在 Google-API 网站上使用 API Explorer 时是否显示了正确的尺寸?
-
是的,我尝试使用“大小”字段获取请求。显示正确的尺寸
标签: java google-drive-api google-api-client