Inconsistent base64 decode File Write

23 views
Skip to first unread message

Ricardo Fernández Serrata

unread,
May 18, 2022, 1:08:50 AM5/18/22
to Automate
Please download the attached file for easier understanding.
I'm generating a solid-color image using a Javascript canvas, then passing it to AM as base64 to write and decode the image to storage for further use. The problem is that sometimes depending on the color and size of the image, Java throws a "bad base64" error. The weirdest thing is that switching between 16x16 to 32x32 size (and viceversa) magically solves the error for some images. The good news is that this is deterministic, so it should be easy to reproduce.

I already tried using `urlDecode`, but there's no difference, because the URI is already URL-safe, AFAIK. I gave up trying to debug what am I doing wrong. I guess I have to transcode the base64 to a "dialect" that AM can understand, maybe by using `replaceAll`? or should I use the `base64` shell commamd?
Solid BG.flo

Ricardo Fernández Serrata

unread,
May 18, 2022, 1:09:51 AM5/18/22
to Automate

Henrik "The Developer" Lindqvist

unread,
May 18, 2022, 8:05:21 AM5/18/22
to Automate
Maybe, but is see little reason the Canvas would produce invalid Base64.
I suspect the problem is due to % (URL) encoding of the data: URL since those do not use URL safe decoding, neither does the File write block.
Try using the Content copy block instead, it supports data: URL decoding, even when the "unsafe" URL characters have been % encoded.

Ricardo Fernández Serrata

unread,
May 18, 2022, 1:15:22 PM5/18/22
to Automate
Thanks! It solved the problem for all images
Reply all
Reply to author
Forward
0 new messages