Add missing foreign key to file table in the image model
Add support for file resources and made some optimizations