Reputation: 441
I am trying to upload a file from my Android app which I am able to. But before that I want to check the available space on my Google Drive.
I am using Google Drive API (version 2). I tried multiple option but wasn't able to find that information.
Can someone tell me how to fetch the Google Drive free space.
Upvotes: 2
Views: 2056
Reputation: 76001
Look at the sample Java code for the About: get
method, which returns the total quota and the user quota in bytes. Calculating the free space remaining should be a trivial task from there.
Upvotes: 0
Reputation: 4574
have a look at this great sample: Documentation
private static void printAbout(Drive service) {
try {
About about = service.about().get().execute();
System.out.println("Current user name: " + about.getName());
System.out.println("Root folder ID: " + about.getRootFolderId());
System.out.println("Total quota (bytes): " + about.getQuotaBytesTotal());
System.out.println("Used quota (bytes): " + about.getQuotaBytesUsed());
// TOTAL - USED = FREE SPACE
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
}
Upvotes: 5