I'm writing a class interface that needs to return references to binary files. Typically I would provide a reference to a file as a file path. However, I'm considering storing some of the files (such as a small thumbnail) in a database directly rather then on a file system. In this case I don't want to add the extra step of reading the thumbnail out of the database onto the disc and then returning a path to the file for my program to read. I'd want to stream the image directly out of the database into my program and avoid writing anything to the disc unless the user explicit wants to save something.
Would having my interface return a FileStream
or even a Image
make sense? Then it would be up to the implementing class to determine if the source of the FileStream
or Image
is a file on a disc or binary data in a database.
public interface MyInterface
{
string Thumbnail {get;}
string Attachment {get;}
}
vs
public interface MyInterface
{
Image Thumbnail {get;}
FileStream Attachment {get;}
}