When you call a REST query for files with no id argument.

domain/site/file.json will call this hook with a NULL $file. 
domain/site/file/5.json will call it with a populated $file