Note that there are some explanatory texts on larger screens.

plurals
  1. PODownload File from Google Drive in Java
    primarykey
    data
    text
    <p>My end goal is to write a simple program that downloads one specific Google spreadsheet at the end of each week to my local hard drive. The file will be edited on a week to week basis by other people, and I will constantly need to download the updated version to pull out data and pass to a bash script that I have written. I am now doing this manually, but if I can pull down the spreadsheet in a csv format, can automate the entire process.</p> <p>I am slightly confused by Google's Documentation. I have copied their example method <code>downloadFile</code>, but am still unclear about the exact parameters that are being passed, and the <code>InputStream</code> return.</p> <p>If I were to add a main method to call the <code>downloadFile</code> method, what would be example parameters that I pass. </p> <p>Then, can I use the <code>InputPut</code> stream it returns to save the file is csv format? </p> <p>Also, is this the only method I need or do is there more to it? </p> <p><code>downloadFile</code> method is defined here (left out the import statements): </p> <pre class="lang-java prettyprint-override"><code>private static InputStream downloadFile (Drive service, File file) { if (file.getDownloadUrl() !=null &amp;&amp; file.getDownloadUrl().length() &gt; 0) { try { HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl())).execute(); return resp.getContent(); } catch (IOException e) { e.printStackTrace(); return null; } } else { return null; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload