public GoogleDriveDownloadTask(String fileName) { if (DriveUtil.service == null) { try { DriveUtil.getDriveService(); } catch (GeneralSecurityException | IOException | URISyntaxException e) { MAMUtil.writeLog(e); e.printStackTrace(); } } ArrayList<String> fileList = new ArrayList<String>(); fileList.add(fileName); this.fileList = fileList; this.totalFileNumber = 1; }
private InputStream downloadFile(String fileName) throws IOException { File file = DriveUtil.getFileByName(fileName); if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) try { fileSize = file.getFileSize(); return DriveUtil.service.files().get(file.getId()).executeMediaAsInputStream(); } catch (IOException e) { e.printStackTrace(); MAMUtil.writeLog(e); return null; } return null; }