Ok …
This works for me. Note this opens up everything and may not be what you want in production, but it should prove a point :
# Add this
r = anvil.server.HttpResponse()
# ...your DB save here...then :
r.headers['Access-Control-Allow-Origin'] = '*'
r.headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
r.headers['Access-Control-Request-Method'] = '*'
r.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
return r
You also need to set the content type when making the API request.
If I do both of those things then it writes my file image to the DB.
I tested using : https://resttesttest.com/
I added a Content-Type header as “image/png”
I added a png image
and it worked.