0

Quick question. Minimal drama. If I'm using a RDBMS like MySQL, can I save a media file (like an image for example) to a database as a BLOB (or any other datatype)? How would I "render" the BLOB? What about videos?

In the past, I have just saved the file to the file system and then saved a permalink (relative/absolute path) in the database. When I want to retrieve the media file, I typically use the permalink to access the media.

Now I'm wondering, "Why can't I just save the media file to the database?"

What do?

ihodonald
  • 745
  • 1
  • 12
  • 27
  • 2
    Yes you can save media files in a database as a blob. Most databases will offer API's to access the BLOB as a collection of bytes, not much different from how you access a file - that also behaves like a stream of bytes. How exactly you're going to render the blob depends highly on the used db, and your programming stack. – fvu Oct 21 '17 at 23:57
  • @fvu Is that just for images/photos or is that for all media? Like, audio, for example. Can you store audio as a BLOB and "render" it? – ihodonald Oct 22 '17 at 00:00
  • 1
    Yes, as I said, a BLOB is just a collection of bytes, just as anything else on a computer. Just feed that stream into whatever you use as "rendering thing" and you're in business. – fvu Oct 22 '17 at 00:07
  • 1
    Read this thread https://stackoverflow.com/questions/154707/what-is-the-best-way-to-store-media-files-on-a-database – Mirza Sisic Oct 22 '17 at 01:54

0 Answers0