![](/img/trans.png)
[英]Create Spreadsheet using Google Spreadsheet API in Google drive in Java
[英]Java :Not able to download spreadsheet using google drive API
我正在嘗試使用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”,然后單擊execute。我收到此錯誤:“ code”: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);
}
根據您得到的錯誤...
https://developers.google.com/drive/v3/web/manage-downloads
嘗試在您的GET請求中添加“?alt = media”。 我的猜測是您在輸入參數中缺少某些內容,或者可能無權訪問媒體(也許未登錄?)。 如果看不到您嘗試調用的實際代碼或發出的請求,我將無濟於事。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.