How to pass byte array from front end to backend?

For testing, I built the same codeless code on the front end and the back end to upload an image. The frontend call works, but when I pass the same byte array (Uint8Array) from the front end to the back end, it seems to get stringified or something and doesn’t work.

The question is, how would I pass a byte array from the front end to the back end without it being “changed” or whatever is happening that the data isn’t the same when it arrives at the backend.

Frontend code -

Backend code for testSirv -

Hello @Tim_Jones,

Could you please try setting the Content-Type header to application/octet-stream when sending the byte array.


I tried that with no luck. I printed out the value of the array before I sent it to the API, and then have the API do nothing but return the data -

You can see the array is being converted to an object (I think) -

The data is still there, but the format isn’t the same. Is that because the API parameter is set to string?

I got it working, but it feels very clunky.

I take the fieData string, and convert it to an object. Then, in the custom code, I convert the object to an array and then convert the array to a Uint8Array.


This can’t be the most efficient way to do this, so I’m hoping you can help me come up with something better.

EDIT - In testing, this is way too slow to be useful in production.


I don’t have to pass a byte array. I am trying to pass an image (array buffer?) from the front end to the backend. I don’t care how it is done.


Unfortunately, the approach will not work without additional workarounds that can affect performance. Because an API service running in Backendless can accept requests only with the application/json Content-Type for POST and PUT requests.
If you need to send a file, you’d need to encode the file contents in the request body. Please use base64 encoding for this purpose.


YES!!! Thanks @Alexander_Pavelko. I was about to lose it if I couldn’t get this to work.

Thank you,

1 Like