List of usage examples for com.google.api.client.googleapis.media MediaHttpDownloader setChunkSize
public MediaHttpDownloader setChunkSize(int chunkSize)
From source file:org.blom.martin.stream2gdrive.Stream2GDrive.java
License:Apache License
public static void download(Drive client, HttpTransport ht, String root, String remote, String local, boolean progress, float chunkSize) throws IOException { OutputStream os;//from ww w . ja v a2 s.co m if (local.equals("-")) { os = System.out; } else { File file = new File(local); if (file.exists()) { throw new IOException(String.format("The local file '%s' already exists", file)); } os = new FileOutputStream(file); } String link = findFile(client, remote, root == null ? "root" : root).getDownloadUrl(); MediaHttpDownloader dl = new MediaHttpDownloader(ht, client.getRequestFactory().getInitializer()); dl.setDirectDownloadEnabled(false); dl.setChunkSize(calcChunkSize(chunkSize)); if (progress) { dl.setProgressListener(new ProgressListener()); } dl.download(new GenericUrl(link), os); }