Skip to main content
Question

How to get file size using Python Box API

  • May 22, 2025
  • 1 reply
  • 10 views

Forum|alt.badge.img

Hi, 

 

To get the file size, i am using the parameter size

for files in folder_1:
    if files.type != 'folder':
        print(files.size)

But i am getting an error saying 

AttributeError: 'File' object has no attribute 'size'

 

This page lists size as an attribute the get the file size. What am i missing? 

https://developer.box.com/reference#file-object 

1 reply

Forum|alt.badge.img

 by default the Get Folder Items endpoint only returns mini representations of the File object, which does not include the size. Pass the fields parameter into the API call with a comma seperated list of fields you want for each file/folder, e.g. "name,size,id,type"