Good day! As you know, a kind of tables appeared in sql server - file tables, File tables. I have an asp.net mvc web application that uses sql server 2012 database. Some text articles are stored in the database. The articles use many links to images that are stored in the file system. The problem is that when backing up the database and then deploying the backup, you must also take care of archiving and subsequent unarchiving of all images (links to which, as I said, are stored in the database). It is here that I would like to apply this very FileTable technology so that the images themselves are still stored in the file system, but at the same time the sql server would “know” about them through FileTable. In the end, I started such a table, added my own files to it, but now I don’t know how to access them from a web application, so that it looks the same as a call to regular files. I can open the storage location of these files from the sql server management studio interface (right click on my file table, select the Explore FileTable Directory item), I see all my files there, but I don’t know how to use them. Suppose I want to put an image from this folder on a web page. What do you need to write to the img tag? Previously, it was like this:

<img src='/images/mypicture.png' /> 

Now I tried this:

  <img src='\\sql-server-name\mssqlserver\MyFiles\mypicture.png' /> 

Unfortunately it did not give a result.

I wish that I could still refer to these images in the same way (that is, that the images themselves did not move anywhere), but at the same time that my database had a file table that would refer to this folder. Maybe I somehow looked inattentively, but when I tried to reproduce it, I did not succeed.

  • Have you ever read any articles on this issue? the essence of these FileTables was to use the select query to output data from a file, while the table itself stores only the file ID, and the server then loads the data from where. Therefore, in your case, the extraction of images should be done using a script, so The src attribute should have a link to the php code that extracts the file from the database and send them to the client with the necessary header headers. - teran
  • that is, it is a kind of alternative to binary fields, when tables instead of a real binary field store references to files containing data. - teran
  • Speech in a question not about pkhp. but essentially it does not change. Another option is that the picture can be encoded directly in the src value using base64. - teran
  • @teran is good, only the main problem is large files. The fact is that I would like to apply this approach not so much to images as to video. To store a large video in the database and drag it with each request from the database turns out to be expensive - Pupkin
  • one
    "It used to be like this ..." - leave it that way. You need to make the url /images/mypicture.png match the physical location of the file. To do this, for example, in IIS, configure a virtual directory (match /images with \\sql-server-name\mssqlserver\MyFiles ). Or, as you have been advised, in the application add a controller, the action of which will give the desired file. - i-one

0