Take the 2-minute tour ×

I am using 'quotaBytedUsed' property while getting Files using an authorized get request - Files.list.

I am converting the long value obtained to file size in KB/MB/Gb as appropriate.

However, size of all folders obtained is 1 KB. This value doesn't reflect the sum total of sizes of all content in the folder.

How can I get the this sum ( if possible without any extra request to server )?

Code used for converting 'quotaBytesUsed' to file size is

private string[] SizeSuffixes = new[] { "B", "KB", "MB", "GB", "TB" };

private string SizeConvert(long? fileSize)
        if (!fileSize.HasValue)
            return "";

        var size = fileSize.Value;

        if (size <= 1024)
            return "1 KB";

        var suffixIndex = 0;

        while (size > 1024)
            size = size / 1024;


        return size.ToString(CultureInfo.InvariantCulture.NumberFormat) + " " + SizeSuffixes[suffixIndex];
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You are getting the size of the folder object, not its contents. The api doesnt support getting a folder content's size. Given that the same file/folder can be in multiple folders, I doubt it will ever be supported. You need to recursively calculate it, using appengine task queues for example.

share|improve this answer
add comment

Your Answer


