I’m thinking to finally switch from images in the db to filesystem approach. One question bothers me, sooner or later I’ll be in position to delete entity, in that situation I no longer need linked image(s). So, to simplify, entity model will have only one field varchar to track imagepath on the filesystem.
Any thoughts?
One more thing, since I’m moving to filesystem image storing I’m curious is following order is ok or is there better approach
1. administrator will upload image to the server using mvc form, browse -> upload btn
2. Creating new entity with entering some data into web form and using javascript select images from the server and store it's filename into entityimagepath property
3. On the client side browser will render <img src=imagepathfromdb ... />
Thanks for your time
You can enlist File IO operations in a database transaction, so that the delete of the row in the DB containing the file’s path on disk and the delete of the file itself can be done transactionally.
http://www.codeproject.com/Articles/31270/A-Transactional-Repository-Implementation-in-NET