Base64Decode Question

I am calling a Python Flask REST service which returns a Base64Encoded file result.

In FileMaker, I am first writing that Base64 data to a text field and then doing a Base64Decode("text field; path_to_file).

Since Base64Decode doesn't seem to work on a variable like $base64Encoded that the INSERT FROM URL creates as its target, I created this extra step. Also INSERT FROM URL, if I used a field instead of a variable, doesn't let me use a function on the Target field result.

So, three script lines which isn't too bad.

I wanted to ask though if I missed something about how Base64Decode works. Since it wants a "field" and not a variable, I added the extra step to the script.

Thanks for any suggestions for improvement.

1 Like

Hi Oliver,

I am somewhat surprised to hear that Base64Decode is not working directly on variable argument if that variable does indeed contain just a Base64 text representation of some data. Never have I had such an experience, nor would I have expected it.

Similarly, I am surprised to hear that the function is not allowed to be called on a text field.

It is entirely possible that you have simply run into something that I have never seen, but for the record, and in case it helps, I will mention that I find it odd. I wonder if there is some nuance about the data being returned which needs to be discovered?

Kind regards,

-Steve

2 Likes

https://help.claris.com/en/pro-help/content/base64decode.html?Highlight=base64decode

This page in FileMaker Help is not clear as spring water. Base64Decode should take its first argument anything that is a text. Don't forget that what will be decoded is binary, hard to check in the DataViewer.

Since Base64Decode doesn't seem to work on a variable like $base64Encoded that the INSERT FROM URL creates as its target, I created this extra step. Also INSERT FROM URL, if I used a field instead of a variable, doesn't let me use a function on the Target field result.

Can you develop on this ?

Three years ago I had a hard time decoding some base64 encoded data retrieved in Xojo from FileMaker. Doing tests I discovered that encoding on Windows and MacOS did not provided the same result, the reason being the delimiter added at every 76 chars - data is split every 76 characters, but the end-of-line sequence depends on the OS.

This Base64 Encode and Decode - Online may help you diagnose what's going on.

3 Likes

I tried using the $ variable, but the Base64Decode function said it couldn't find the field. If you could show me how you use the Base64Decode with a variable directly, say a screenshot or FMP sample, that would be helpful.
Thanks @planteg!

Hello Oliver,

Attached should be a very simple example of using Base64Decode, where its supplied base64 data is held within a variable.

Hope this helps!

-Steve

Base64.fmp12.zip (103.1 KB)

2 Likes

Now that's just strange.

It now works for me also, but when I tried it last time, I got some "could not find field" type error. Maybe a typo (user error....), don't know.

Thanks, @steve_ssh!

Excellent.

1 Like