Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
nickthehero
8 years agoExplorer | Level 3
Java API - What is the best way to get a user's remaining free space using DbxClientV2?
subject is self-explanatory. I can't seem to find any good info on the matter. I'm not sure exactly how storage values work in V2, as the docs are a bit... ambiguous. Or else i just cant find the right info. Best way to get this info? Thanks in advance :D
3 Replies
- Greg-DB8 years ago
Dropbox Community Moderator
To get the user's space usage via the API v2 Java SDK, you should use DbxUserUsersRequests.getSpaceUsage. That will return a SpaceUsage object, which contains information about their 'allocation' (their total quota) and their 'used' (the amount of space they're currently using. To get the "free" amount, subtract the 'used' from the 'allocation'.
Note that their 'allocation' will be a SpaceAllocation object with more detail information so you can distinguish between shared team quota (if they're on a team, since team accounts share their quota) or individual quota.
If you're having trouble writing code to get the specific value you want, please share the code you have so far and let us know what you're stuck on.
- nickthehero8 years agoExplorer | Level 3
Greg-DB wrote:
To get the user's space usage via the API v2 Java SDK, you should use DbxUserUsersRequests.getSpaceUsage. That will return a SpaceUsage object, which contains information about their 'allocation' (their total quota) and their 'used' (the amount of space they're currently using. To get the "free" amount, subtract the 'used' from the 'allocation'.
Note that their 'allocation' will be a SpaceAllocation object with more detail information so you can distinguish between shared team quota (if they're on a team, since team accounts share their quota) or individual quota.
If you're having trouble writing code to get the specific value you want, please share the code you have so far and let us know what you're stuck on.
It's not clear what their total allocation of their dropbox is then, so this answer only help me partially.
Does their whole personal dropbox size = .getSpaceUsage.getAllocation.getIndividualValue.getAllocated ?
- Greg-DB8 years ago
Dropbox Community Moderator
Yes, that would make sense for a personal, not Business, account. Here's a basic example that checks the type to handle either:
SpaceUsage spaceUsage = client.users().getSpaceUsage(); long allocated; if (spaceUsage.getAllocation().isTeam()) { System.out.println("Team allocation:"); allocated = spaceUsage.getAllocation().getTeamValue().getAllocated(); } else { System.out.println("Individual allocation:"); allocated = spaceUsage.getAllocation().getIndividualValue().getAllocated(); } System.out.println("Total: " + allocated); long used = spaceUsage.getUsed(); System.out.println("Used: " + used); System.out.println("Free: " + (allocated - used));
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!