Has anyone successfully deployed a function that returns binary data, such as an image/png or audio/wav? I have with other functions had to base64 encode / decode etc, but want to avoid this due to the size and compute required for my application function. I just want the functions to return the binary data as provided to appwrite by my function. Currently running self hosted, latest 1.7.4 version. Its a simple python 3.12 deployed appwrite function that just returns the raw binary data and content-type of audio/wav, very much like the docs for functions that returns an image/png if you request a type of binary. The documentation shows doing almost exactly the same thing I'm doing where I'm opening the binary file and returning the bytes.
python code, tried each of the following:
return context.res.binary(wav_file_bytes})
return context.res.binary(wav_file_bytes, 200, {"content-type": "audio/wav"})
return context.res.binary(wav_file_bytes, 200, {"content-type": "audio/wav; charset=ISO-8859-1"})
The last one because the python 3.x open-runtimes insist on adding '; charset=utf-8' to any content-type that does not begin with 'multipart/' and I thought this was triggering the error.
The actual executions page successfully shows a 200 status code for the function's returned result, but once Appwrite internally processes the result, it has an error due to trying to then json decode that data.
The following error in 'appwrite' logs:
[Error] Method: POST
[Error] URL: /v1/functions/:functionId/executions
[Error] Type: JsonException
[Error] Message: Malformed UTF-8 characters, possibly incorrectly encoded
[Error] File: /usr/src/code/src/Appwrite/Utopia/Response.php
[Error] Line: 825
I can see why its complaining because an audio/wav (or png or many other binary file types!) will contain data that is not valid utf-8.
How is an Appwrite (python) function supposed to return binary data to stop Appwrite further trying to process it and encode it wit utf-8?
Recommended threads
- Selfhosted Github App installation
I've followed this guide: https://appwrite.io/docs/advanced/self-hosting/configuration/version-control to connect GitHub to my self-hosted Appwrite instance (1....
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...