Related: Storing Images in DB - Yea or Nay?

After reading through the above mentioned question, it appears the most well-liked way of image storage with databases would be to store just the filepath inside the database. However, many of these solutions appear to pay attention to web servers.

During my situation, I am creating a desktop application that'll be used across multiple computer systems inside an intranet. A devoted server will host the database, that contains information associated with carrying out tests on various equipment.

Images have to be saved around the server in some manner. Would storing the pictures within the database function as the correct approach within this situation, or perhaps the only approach?

Pros:

  • Backup is restricted to simply the database.
  • You don't need to open the server's file system towards the network.
  • Single protocol for server information access.
  • Protected file access. (User can't use and remove all of the images)

Cons

  • Performance issues later on if there's a lot of images.

Edit: As mentioned within the tags, the applying has been designed in C#/.Internet. If writing the pictures towards the file product is a choice within this situation, I possibly could apply certain help focusing on how this is accomplished.

Edit 2: As elaborated some within the comments below, for the time being I am presuming a MySQL database, even though FileStream abilities of SQL Server 2008 may potentially change that.

Also during my situation, images is going to be added frequently, and can be viewed as read-only following this point given that they will not be transformed, and can you need to be read out if needed. Images will probably be small (~70k each), and I am also thinking about another binary format storage around the server, files that are ~20k each that we can likely apply exactly the same method for storing and locating.

I'd suggest keeping individuals files on disk within the file system, instead of within the database. File system for files, databases for relational data, etc.

Deliver by Web Service

Consider delivering individuals images for your desktop application by hosting an internet service/application on that DB machine. That app's job it's for everyone only images. Setup an internet server on that machine by having an ASP.Internet application. Come with an .ashx handle demands and stream the binary image. Something similar to this:

http://myserver/myapp/GetImage.ashx?CustomerID=123&ImageID=456

Security

If intranet security is definitely an problem, this is the stage where you can be sure that the user is authenticated and approved for read accessibility image. Audit trails might be implemented because well.

File System Security

Regarding security on individuals images, take into account that NTFS gives you plenty of measures to make sure that only individuals who're approved can seeOrremove/put files as needed. The job then is always to define individuals roles and implement Home windows security groups.

Future Needs

This method enables you to definitely safely consume individuals images everywhere around the intranet. Possibly this application could be migrated to some web application sooner or later? Possibly an element request originates from the client in which a web option would be appropriate?

This may seem like overkill instead of reading through a blob in the database, but it is great from the security perspective. Consider your customers' and patients' anticipation on security and privacy.

<%@ WebHandler Language="C#" Class="Handler" %>

public class Handler : IHttpHandler {

public void ProcessRequest (HttpContext context) 
{
    //go to the DB and get the path for this ID.
    string filePath = GetImagePath(context.Request.QueryString["ImageID"]);

    //now you have the path on disk; read the file
    byte[] imgBytes=GetBytesFromDisk(filePath);

    // send back as byte[]
    context.Response.BinaryWrite(imgBytes);
}

If you're able to use Sql Server 2008, take a look only at that link

Saving and Retrieving File Using FileStream SQL Server 2008