I went through some of the videos and articles done by Lauren Schaefer and Drew DiPalma about what could be done with Realm Serverless, and decided to see if I could run before I start walking. So I decided to write a Realm Serverless Function that could handle image uploads from our mobile client and post them into our Cloudinary account as an example.
Basically in the client we create a Data URI from the image and we found out that there are limits to the BSON Parameters that we could send. It seems that limit is around 10KB. So once that was determined, we chunked the fileData argument into a BSONArray of BSON strings.
The code works fine with almost any image size if I run it in Node.js (Nice trick using the module.exports = exports from Lauren’s video), and it does work in the Realm Serverless if the image is small (I’ve tried 13KB, not sure that’s the limit), and it seems to not work on images that are around 300KB. It seems that it’s timing out on my axios request. (I imported crypto, and axios as node_modules into my Realm Application). As the console.log shows that it makes it to that request. (… 'About to upload to: ')
Disclaimer: I’m actually not looking for the response of that you shouldn’t use Realm Serverless Functions for this, (we’re willing to concede this already.), however it would be better to know what the limits are so we can determine what kind of use cases make sense for Realm Serverless Functions.
What could be the reason for the timeout as the normal 13KB request takes about < 5 seconds?
Realm Serverless Source