Handle Images and Video in C# EF 6 -> Recommended maximum file size

c# entity-framework entity-framework-6

Question

In our business application we handle images and videos. I have created the Entity Framework model based on this answer:

https://stackoverflow.com/a/6241232/3850405

I know this will result in varbinary(MAX) which has a limit to around 2 GB since EF does not support FILESTREAM out of the box.

https://stackoverflow.com/a/5723825/3850405

What I can't find however is what the recommended maximum file size is? I know that this could fall under opinion based but I hope that the given context allows it. For images I was thinking around 5 mb and videos 200 mb and only fetch them when the user want's to see them (Name will be showed in Front End).

Is this a good solution or should I rethink this all together? Would it be beneficial to implement FILESTREAM even though it is not supported by default?

Current model:

public class Media
{
    [Key]
    public int Id { get; set; }

    public DateTime Created { get; set; }

    public DateTime Updated { get; set; }

    public virtual ICollection<Image> Images { get; set; }

    public virtual ICollection<Video> Videos { get; set; }
}

public class Image
{
    [Key]
    public int Id { get; set; }

    public DateTime Created { get; set; }

    public DateTime Updated { get; set; }

    public string Name { get; set; }

    public virtual byte[] Image { get; set; }

    public int MediaId { get; set; }

    public virtual Media Media { get; set; }
}

public class Video
{
    [Key]
    public int Id { get; set; }

    public DateTime Created { get; set; }

    public DateTime Updated { get; set; }

    public string Name { get; set; }

    public virtual byte[] Video { get; set; }

    public int MediaId { get; set; }

    public virtual Media Media { get; set; }
}
1
0
6/14/2017 9:48:49 AM

Popular Answer

There isn't really any objective way to decide what your maximum should be.

SQL only provisions what is needed by your data anyway so if you have used varbinary(max) for your column data type and you only have a 200MB video file going in there, it doesn't matter that the field has a capacity of 2GB because its only using 200MB.

With that in mind, I'd suggest using varbinary(max) anyway unless you know for a fact exactly how big every file is going to be. That way you can be sure there'll be space for it and you won't have your data being truncated to fit.

0
6/14/2017 10:20:38 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow