Пример #1
0
 private string[] GetUserDetails(DriveService service)
 {
     string[] details = new string[2];
     AboutResource.GetRequest request = service.About.Get();
     request.Fields = "user(emailAddress, displayName)";
     details.SetValue(request.Execute().User.EmailAddress, 0);
     details.SetValue(request.Execute().User.DisplayName, 1);
     return(details);
 }
Пример #2
0
        private long GetGoogleDriveSpaceAvailable()
        {
            long storageAvailable = -1;

            AboutResource.GetRequest getRequest = driveService.About.Get();
            getRequest.Fields = "*";
            About about = getRequest.Execute();

            long?storageLimit = about.StorageQuota.Limit;
            long?storageUsage = about.StorageQuota.Usage;



            if (!(storageLimit is null || storageUsage is null))
            {
                long storageLimitValue = (long)storageLimit;
                long storageUsageValue = (long)storageUsage;

                storageAvailable = storageLimitValue - storageUsageValue;
            }

            logger.LogDebug($"Google account space limit (bytes): {storageLimit}");
            logger.LogDebug($"Google account space used (bytes): {storageUsage}");
            logger.LogDebug($"Google account space available (bytes): {storageAvailable}");

            return(storageAvailable);
        }
Пример #3
0
        public About getUserDriveInfo(DriveService service)
        {
            AboutResource.GetRequest getRequest = service.About.Get();
            getRequest.Fields = "*";
            var about = getRequest.Execute();

            return(about);
        }
        /// <summary>
        ///     <inheritdoc cref="ICustomGDriveService" />
        /// </summary>
        public long GetQuotaTotal(DriveService service)
        {
            var ag = new AboutResource.GetRequest(service)
            {
                Fields = "user,storageQuota"
            };
            var response = ag.Execute();

            if (response.StorageQuota.Limit.HasValue)
            {
                return(response.StorageQuota.Limit.Value);
            }
            return(-1);
        }