Results 1 to 6 of 6
- 12-12-2009, 04:58 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 1
- Rep Power
- 0
retrieve file containg image from database
Hi all,
I have doc file containing images and i stored it in to database Blob type.
I retrieved that file from database and written the content to new doc file.
but the resultant doc file is not containing images instead it is containing binay data of images. But i want doc file with original images how to solve it
please help me for this.
- 12-13-2009, 11:07 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Storing images in DB is not very good solution.
First it is not natural to store a lot of data in DB that has to be retrieved later.
Second when you store it, you cannot open img file easily from out of DB.
Mostly used approach is to store images on file system, and store their names in DB tables as regular txt or varchar column type.
You have only to match the data in the column with file name in your file system in proper way.
regards :)
- 12-14-2009, 10:39 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Couldn't disagree more.
You store data in a database. Images are data.
Now, some DBs are not as good as others at this. I'm not entirely sure it's possible in Access, for example. But Oracle, SQLServer, Postgres work.
As for reading it out of the db? That's just as easy as reading it from a file.
The other advantage of having it in the db is data integrity. The db will now be handling all your data, and not just part of it, so the integrity will be far easier to maintain.
As for lots of data. That's what DBs are for!
Anyway, it appears the OP is storing a .doc file (ie word document), that contains images, and not an image file itself.
So, for the OP, how are you writing this to the db from the doc, and how are you reading it back?
- 12-14-2009, 10:53 PM #4
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Tolls thank you very much for your post,
i have discussion on this topic with my colleagues
and most things you have written are correct.
This is what forums is about - rethinking and finding good second opinion:)
DB admins told me that this things has to be considered
on file-system vs. DB topic:
1) Cost and capacity - do you use your own DB server or is it hosted somewhere, let's say ISP gives you 50MB in some MySQL DB.
There are folder issues depending on your OS - MAX physical number of files in folder, so you have to make a logic to map filenames from many different dirs to actual files in DB...
2) Speed - indexed paths in File System with help of lucene can increase speed when you compare it to DB file writing. There are many type of file systems for different OSs, some or better to store bigger files...
Rethink how often you do replication and backup of your huge DB if files are in it. Everyone knows hot to copy files to another location and it is fast.
If you backup again, it is even faster - just use SKIP when same file is
to be copied again
3) security - definitely better if files are in DB.
You don't have to think about file and folder permissions,
specially if server is not yours (you use ISP)
Delete, insert, update problems:
If you delete some record in DB that has file associated with it,
you are responsible for writing code that deletes the file from file-system,
or you will have orphan files.
On contrary if file is in DB, you can use it in SQL queries if you need it
and use cascades to delete it easily when parent is deleted.
Think about possibility to move application from Windows to Linux
and problems you may have with different file system nature, permissions...
if you use file system to store your files
Looking forward to here more opinions from forum members
and hope we will solve your problem in further posts ;)
- 12-15-2009, 01:50 AM #5
Member
- Join Date
- Nov 2009
- Location
- Abuja, Nigeria
- Posts
- 15
- Rep Power
- 0
- 12-15-2009, 09:10 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Retrieve Image From Hard Disk
By sayan751 in forum AWT / SwingReplies: 3Last Post: 02-20-2009, 03:29 PM -
image insertion into database
By abhiN in forum JDBCReplies: 4Last Post: 01-05-2009, 05:09 AM -
How to store/retrieve PNG image in/from RMS
By jason-nexFIT-mobileXware in forum CLDC and MIDPReplies: 0Last Post: 09-10-2008, 04:01 AM -
Retriving image from database
By Java Tip in forum Java TipReplies: 0Last Post: 02-09-2008, 08:41 PM -
passing image file to database
By abhiN in forum Advanced JavaReplies: 2Last Post: 01-21-2008, 06:30 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks