How can I save and retrieve images i开发者_运维知识库n Blob field in Oracle using C#? Is it a good choice to use database to store image?
Since you're using C#, you probably want to start with Microsoft's Working with Oracle LOBs. That has a number of examples of reading and writing LOBs to an Oracle database using the OracleLob class.
As to whether it is a good idea to use the database to store images, as with all things, it depends. Storing images in the database ensures that images are protected by transactional integrity. It provides a single place where all the images can reside that will, by definition, be accessible to all the middle tier servers. It makes it much easier to ensure that all the data is backed up and can be recovered. It ensures that no one accidentally moves an image without remembering to update the database.
On the other hand, it means that the size of the database may grow substantially and thus be harder to back up. Presumably, this is just trading database backup size for file system backup size, but this may involve shifting headaches from one group in the organization to another. It means that you can't manage the images on the file system using file system scripts. It may make it more difficult to cache the images on the middle tier.
I am not aware of what programming language you are using, but just open your file and write the bytes using Hexadecimal notation.
Here is a example in Java programming language: http://www.herongyang.com/JDBC/Oracle-BLOB-SQL-INSERT.html
Edit:You may save the pixels, or compress the image before(in the webcam case). I recommend that you use something like JPEG or PNG before saving the image on the database.
精彩评论