Jenelle
Jenelle

Reputation: 21

In GoogleDocs App, file size is always 0 (zero) for google files (but non-native files like MS Word/Excel have non zero size

var files = DocsList.getFolderById(release[index]).getFiles();

  for(i in files){
    /*** Title field ***/
     var title = "<a href=\""+files[i].getUrl()+"\">"+ files[i].getName() +"</a>";
    /*** Size field ***/
     var size = files[i].getSize();
    /*** Owner field ***/
     var owner = files[i].getOwner().toString().substring(0,files[i].getOwner().toString().indexOf('@'));

getSize always returns Zero (0) for google files (document, presentation, spreadsheet). But from the Google Drive Resources menu, I can find word count, character count....and for non-google files (i.e., Word or Excel) a size appears.

Here's the method syntax (https://developers.google.com/apps-script/class_file#getSize). Does size require some kind of substring or tostring? what else do I need to add?

Upvotes: 2

Views: 1492

Answers (1)

Eric Koleda
Eric Koleda

Reputation: 12673

As Nick Johnson said in the comments, this is working as intended. In the Google Drive UI if you sort by "Quota used" you'll see that Google Docs and Spreadsheets don't have a file size.

Upvotes: 1

Related Questions