Skip to main content

Explicitly requesting the extension attribute from the BoxFile.Info object’s getInfo method provides the expected value.


However, if requesting the entire BoxFile.Info object’s getInfo’s set of attributes, not explicitly specifying fields to be returned, the extension attribute value is missing.


In addition, the SHA1 attribute, which is another specific BoxFile extension to BoxInfo, exists.


I would expect both to be provided, but extension is not.



Attempted with Box Java SDK versions 4.7.0 and 4.8.0.



For example:



BoxFile.Info info = file.getInfo("extension");

System.out.println(info.getExtension());



BoxFile.Info info = file.getInfo("sha1");

System.out.println(info.getSha1());



BoxFile.Info info = file.getInfo();

System.out.println(info.getExtension());

System.out.println(info.getSha1());



Example output:


doc


bddf8a01e139522c81c59b10df840c4379e24cfb


null


bddf8a01e139522c81c59b10df840c4379e24cfb



The null output is unexpected.

Hi,


this is expected behaviour of Box API. By default getInfo method returns File (Standard) variant of BoxFile class. It contains only a subset of all fields, which are available in File (Full) variant. To get any additional fields you have to explicitly pass them in a getInfo method. I see that extension is only in File (Full) variant, so to get it you have to call file.getInfo("extension"). However if you specify only one field there, this will be the only one available except those defined in File (Base) variant. So in order to get both extension and sha1 you have to pass these two params in the method:


BoxFile.Info info = file.getInfo("sha1", "extension");


You can also call:


BoxFile.Info info = file.getInfo(BoxFile.ALL_FIELDS);


to always get all fields.


Best,


Lukasz Socha


Reply