Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Requesting OneDrive Quota #97

Closed
minimalisticMe opened this issue Mar 15, 2016 · 5 comments
Closed

Requesting OneDrive Quota #97

minimalisticMe opened this issue Mar 15, 2016 · 5 comments

Comments

@minimalisticMe
Copy link

Can we have example code in samples to show the following:

  • The total quota of the users OneDrive
  • The used quota of the users OneDrive
  • The amount of quota the authenticated app used in special folder appfolder
@ginach
Copy link
Contributor

ginach commented Mar 17, 2016

Added to the list for documentation requests.

Essentially, quota details are returned on the Drive object and the Size property of an includes the size of the item itself and any children within it. Here are some examples of accessing these values:

Get quota details for a drive

var drive = client.Drive.Request().GetAsync();
var quotaRemaining = drive.Quota.Remaining;
var quotaTotal = drive.Quota.Total;
var quotaUsed = quotaTotal - quotaRemaining;

Get space used by appfolder

var appRoot = await client.Drive.Special.AppRoot.Request().GetAsync();
var appRootSize = appRoot.Size;

@minimalisticMe
Copy link
Author

Thank you very much for the answer.

When you add this to documentation, may I suggest two slight changes:

var drive = await oneDriveClient.Drive.Request().GetAsync();
var quota = drive.Quota;

var quotaRemaining = quota.Remaining;
var quotaTotal = quota.Total;
var quotaUsed = quota.Used;
  1. add the await operator (it's necessary)
  2. point out, that Quota is a class of namespace Microsoft.OneDrive.Sdk and can be obtained this way (in order to process the information further).

@dkonigsberg
Copy link

When I try to get the Drive quota, the Quota facet is coming back as null. If it makes a difference, my client is just requesting access to its app folder, and is using the following permission scopes:
"wl.signin", "wl.offline_access", "onedrive.appfolder"

Should I be able to see the quota, or do I need to request another permission for that?

With the upcoming quota changes for OneDrive itself, I expect a lot of users will be running into quota issues. I'd like to be able to detect these in advance, so I can inform the users before failing to upload.

@dkonigsberg
Copy link

Okay, as a follow-up... Adding the scope "onedrive.readonly" is sufficient to make quota information appear. Hopefully this won't make anything look suspect to a user, when the app really only needs access to its own app folder.

@baywet
Copy link
Member

baywet commented Oct 2, 2024

Thank you for reaching out and for your patience. This SDK is being officially deprecated. See #259 for more information

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants