1

To be honest, I don't have any idea how filestream works. It's my first time using and experimenting on it. So, I was able to store data in a filestream column, but I have no idea how to retrieve it or how it should look after retrieving it. Is it possible to just click a button and then the file in the filestream column will just open? For example, I stored a ms document file in the database, then the file will open in microsoft word or i stored a pdf, then the file will open in a pdf reader. Is it possible?

Im sorry if this is a dumb question. hehe. Thank you.

bananna
  • 13
  • 1
  • 5
  • You might take a look at File Tables. These are stored in the database and use filestream for storage but allow non-transacted access too, so you can access files via UNC path like other files. See https://msdn.microsoft.com/en-us/library/ff929144.aspx. – Dan Guzman Feb 05 '17 at 15:34

1 Answers1

0

FILESTREAM from the developers point-of-view looks no different than a normal varbinary(max) column. This means you will be storing binary large objects (BLOBs). SQL Server will then store those BLOBs as files on the file system, rather than storing them directly in the database.

You can treat it exactly as a varbinary column on the .NET side. Take whatever data you want to store, turn it into a byte array, and save it to the DB.

When you retrieve it, it will again be in a byte array. You will need to do something with it in order for it to be usefull (write it to a file locally, process it and display it, etc.)

Side note, you can also access the FILESTREAM BLOBs using Win32 APIs if you enable it. See this link for more info.

MrZander
  • 3,031
  • 1
  • 26
  • 50