Retrieve file by ID Silverstripe

204 Views Asked by At

I am currently using SilverStripe 4.1 and I am trying to retrieve an image from the database and it always returns null.

When I go to the database I see the file reference in the File table. Here is the File table content for the file I was trying to retrieve:

ID          | 2583
ClassName   | SilverStripe\Assets\Image
LastEdited  | 2018-11-08 21:05:48
Created     | 2018-11-08 21:05:48
Name        | logo-v5.png
Title       | logo-v5
ShowInSearch| 1
CanViewType | Inherit
CanEditType | Inherit
Version     | 1
ParentID    | 1753
OwnerID     | 10
FileHash    | 9e6faa29b752294d2e623bd83b17660df123af62
FileFilename| images/logo-v5.png
FileVariant | NULL

Here are the way I tried:

File::get()->byID(2583); 
Image::get()->byID(2583);  
File::get_by_id('SilverStripe\Assets\Image', 2583);

In all cases is returning null. Do you know what I am missing here?

0

There are 0 best solutions below