title: Get size of files using Google drive API
body: <p>I am trying to list files from google drive along with their sizes for my app &amp; below is the how i tried getting the size</p>
  
  <pre><code>File file = service.files().get(file.getId()).setFields("size").execute();
  file.getSize()
  </code></pre>
  
  <p>I came to know that the size obtained from this call is not right as google drive only populates file size for files apart from google docs, sheet <a href="https://stackoverflow.com/questions/20065308/get-size-of-file-created-on-google-drive-using-google-drive-api-in-android">Get size of file created on Google drive using Google drive api in android</a> </p>
  
  <p>Also I tried determining file's size by making http GET to 
  webContentLink &amp; checking the Content-Length header like below</p>
  
  <pre><code>HttpURLConnection conn = null;
          String url = "https://docs.google.com/a/document/d/1Gu7Q2Av2ZokZZyLjqBJHG7idE1dr35VE6rTuSii36_M/edit?usp=drivesdk";
          try {
              URL urlObj = new URL(url);
              conn = (HttpURLConnection) urlObj.openConnection();
              conn.setRequestMethod("HEAD");
              conn.getInputStream();
              System.out.println(conn.getContentLength());
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              conn.disconnect();
          }
  </code></pre>
  
  <p>But in this case , the file size is not correct as it comes out be very large</p>
  
  <p>Is there any way I can determine the file size ?</p>