Encode and send a small image

Hi, I have a question about sending larger chunks of data. I have a small image file (~15kB) that I would like to occasionally send from the notecard connected system.

What’s the best way to do that?

  1. base64 encode it and just make a json note with a really long string? Is there a size limit here I should be aware of?
  2. Some other binary send function?
  3. Break it up to smaller chunks?
  4. Something else?

Thanks,

Chris

Hey @chris ,

Great question. There are a variety of different ways to solve this. Personally I’ve had the most luck with:

  1. Base64-encoding the file
  2. Splitting it up into 8KB chunks (arbitrary, but this seems to be a “safe” size for limited-bandwidth connections)
  3. Using the web.post API to individually send those chunks to Notehub (and beyond to whatever endpoint you are using)
  4. Reassembling the file on the server (being aware that Notehub will have converted the payload to binary for you)

You can get fancier by also performing a checksum on each chunk to make sure the file transfer was successful.

I’m hoping to put together a bit of a “best practices” guide for this in the near future. In the meantime, we just did a webinar with Edge Impulse on remotely updating ML model files which has a file transfer component.

Hope that helps!
Rob

Yeah, that sounds like exactly what I need. I’ll give it a shot.