MediaMagic: Convert any media file into encoded string or vice-versa

This gem is  written with the intention of converting any kind of file into encoded string or vice versa. The code is available on github.

Possible use cases:

  1. Store an image in database
  2. Store a video in database
  3. Store an audio in database(In short you can store *.* file in database)
  4. Pass a media file as a string in an email, comment, chat conversation etc.
  5. To save entire web page into just a single .html file.

How to use it?

or

Create a Gemfile and write the following into it.

Lets say I have a file available on my desktop Users/ajitsingh/Desktop/image.jpeg .Now I want to encode this file into a string so that I can store it in database.

You can also use an url of a file instead of supplying an actual file.

To decode the encoded string back into the image file use the following code.

 

Leave a Reply

Your email address will not be published. Required fields are marked *