Encode Base64 to image or file

We are able to convert Base64 to an image or file.

I’ve converted this JPG to Base64:

test

/9j/4AAQSkZJRgABAQEASABIAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCABMAKYDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAUBAwQGAv/EABkBAAMBAQEAAAAAAAAAAAAAAAABAgMEBf/aAAwDAQACEAMQAAABygYeqAB78dPztY1ATsAAAAAATDNyu8uUwgBXIDUAJ+2dDvTlEbyK5+chtrjpV53F7z5b3qZzvgpc+axUOLh541j/AMj5mLas++QBQAmbMexw+5vpObvm1OlTVxzjjWBk1V5nHrC5lUp2VWlUJnKaOgAnaQGoATNmO9z0aN5m04J0Z7nPOXOPc9C+/K3cc6092J3ZpoecRukfP0WV598gBBInBIDLSkKxumgWjaleOIYYBXuvVDmyPArbZMg4gknQJGv/xAAlEAACAgEEAwABBQAAAAAAAAACAwEEABARIDMSExQwISIjMUD/2gAIAQEAAQUC4eJfjiJnJiY4RxCNgb2/hpR+671axqIEcprbFjEMlhqMIBZMn4yxiDDQRk5ioeFXYORWbOKXCwsgRh87cmNpyNafbrajzgAgBJwBP95ZV4EhfrWxgrhbRZw8oxvbkcKvfje2mP8AJhCclW39NkfJOWFe2FrYljbIkFbou9WscKvfje2lwZ1ofBDpZVBDW6LvVrHCr35AQy0tQq0ZHiyuv2G5CwV8q8KSUdZssHK/Rd6l11ktwwDcjgkvFuQkYa1nrGJiYNQMwAEIuM0agWSpUKh5+tdQt1mAnH6CJl5HkcVWtom0vZrJaSnEvIuDh25nT6zwbRxk3MMyYQHIFFyNnWJZrH+WM//EACMRAAICAgAGAwEAAAAAAAAAAAECAAMREhATICEiMTJBYQT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hK++Db5mTgXVIWFhNyXntcFsew3IsCwgKPaUj6rWV93eZVrWHPY+/xwLEZTuHUjUIr1TMIR1dXf41jO2djqyP5ua7fTKU/E6T4MCI5i0HI27cPF6cI+rKa6n3EytsK+Zyzg9BF6Ttuj8coj2MBPqNRlxdv4colKlXKurP8AO/6jy/t05HS59OKdpnTdAwDkEr6OEdE5MQKHTJ3nUrQ2+5+uPilSpUqVKlSpUqVKlSpUqVKlSoOyf//Z

Then created a QR Code from the Base64:

In my App the first column is Scanable Text.
Then you can add the Prefix for JPG: data:image/jpeg;base64,

The [Show] column has the expression [Prefix]&[QR].
The same expression I put in the initial value to [Image] and [File] column.

This will produce an image out of the Base64 code.

Same thing is possible with PDF files when you set the Prefix to data:application/pdf;base64,
It will convert the Base64 code into a PDF when using the File column type.

For sure QR Codes are no good choice, because they can contain only max 4296 characters.

Adding @GreenFlux @Jonathon @Bellave_Jayaram

3 Likes

Very cool. Good find, @Fabian.

I wonder if there is a similar prefix that could go the other direction and convert the image to Base64.

1 Like