Convert base 64 image to media object

Good morning, @thai.

The answer is actually in your topic title: convert the base-64 text into your desired media object. This is a two-stage process:

  1. Convert the text to binary. There is a Python Standard Library module for conversions like these. See base64 — Base16, Base32, Base64, Base85 Data Encodings
  2. Convert the resulting bytes object into a Media Object (subtype: BlobMedia). See Constructing Media Objects.

Tip: Once you’ve converted the text into a usable Media Object, you may want to store that object in the row’s image column. Otherwise, the conversion work will have to be done all over again, the next time.

1 Like