2017-05-14 1 views
0

https://developers.google.com/drive/v3/web/migration에서 GDrive v2 API의 about 섹션에있는 QuotaBytesTotal이 storageQuota.limit로 변경되었습니다. QuotaBytesUsed가 storageQuota.usageInDrive로 변경되었습니다. 누구든지 GApis.v3에서 이것을 어떻게 호출 할 수 있는지에 대한 예를들 수 있습니까? 당신이 원하는 나는이 생각Google 드라이브 Apis v2에서 v3으로 QuotaBytesTotal/QuotaBytesUsed를 C# .Net의 v3으로 마이그레이션합니다.

private long GetQuotaUsed(Google.Apis.Drive.v3.DriveService service) 
{ 
    var quotaBytesUsed = service.About.Get().Execute().QuotaBytesUsed; 
    if (quotaBytesUsed == null) 
     return 0; 
    return (long) quotaBytesUsed; 
} 

답변

1

되어 다음 QuotaBytesUsed 정확히 같은 일을 위해

private long GetQuotaTotal(Google.Apis.Drive.v3.DriveService service) 
{ 
    var quotaBytesTotal = service.About.Get().Execute().QuotaBytesTotal; 
    if (quotaBytesTotal == null) 
     return 0; 
    return (long) quotaBytesTotal; 
} 

:

내가 (구글 API를 v2가) 사용 된 예전의 코드는 다음을이었다

public long GetDriveSpaceUsage() 
    { 
     try 
     { 
      AboutResource.GetRequest ag = new AboutResource.GetRequest(_CurrentDriveService); 
      ag.Fields = "user,storageQuota"; 
      var response = ag.Execute(); 
      if (response.StorageQuota.Usage.HasValue) 
      { 
       return response.StorageQuota.Usage.Value; 
      } 
      else 
      { 
       return -1; 
      } 
     } 
     catch (Exception e) 
     { 
      System.Diagnostics.Debug.WriteLine(e.Message); 
      return -1; 
     } 
    } 

    public long GetDriveSpaceLimit() 
    { 

     try 
     { 
      AboutResource.GetRequest ag = new AboutResource.GetRequest(_CurrentDriveService); 
      ag.Fields = "user,storageQuota"; 
      var response = ag.Execute(); 
      if (response.StorageQuota.Limit.HasValue) 
      { 
       return response.StorageQuota.Limit.Value; 
      } 
      else 
      { 
       return -1; 
      } 
     } 
     catch (Exception e) 
     { 
      System.Diagnostics.Debug.WriteLine(e.Message); 
      return -1; 
     } 

    } 
+1

추가적으로 [Drive API Client Library for .NET] (https://developers.google.com/resources/api-lib)을 확인하는 것이 좋습니다. raries/documentation/drive/v3/csharp/latest /). **'UsageInDrive' **와 **'Usage' **는'StorageQuotaData' Class Reference에서 찾을 수 있습니다. 희망이 도움이됩니다. –

관련 문제