【发布时间】:2017-03-01 07:18:20
【问题描述】:
我正在尝试使用 google drive api 从驱动器下载文件
重现步骤: 步骤1: 点击:https://developers.google.com/drive/v3/reference/files/export#try-it 第2步: 我提供了 fileid 和 mimetype 我将 fileid 和 mime 类型指定为“application/vnd.google-apps.spreadsheet”,然后单击执行。我收到此错误: “代码”:403, "message":"导出需要 alt=media 才能下载导出的内容。"
public static void downloadFile(Drive service,String fileId) throws IOException{
OutputStream outputStream = new ByteArrayOutputStream();
//OutputStream outputStream = new FileOutputStream("/Users/xxxxx/Downloads/driveFile.xls");
//service.get
service.files().export(fileId,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
.executeMediaAndDownloadTo(outputStream);
}
【问题讨论】:
-
嗯,你的问题不清楚☹
-
我使用googleapis.com/drive/v3/files{fileid}/export 下载了一个文件。我提供了输入参数文件 ID 和 mime 类型。我得到了错误请求的响应
-
你的代码在哪里?
-
我已经使用了这个链接developers.google.com/drive/v3/reference/files/export#try-it。从这里我得到 403 错误代码。这是我的代码,从代码中我也得到 403 错误代码。我如何粘贴代码,因为它超出了限制,所以这里不接受整个代码
-
@SuvarnaLakshmiGodavarthy,只需编辑您的问题以添加您的代码。
标签: java