Saving image attachments via the rest api

Is there an example of how to save an image attachment? Specifically I need to know how to encode the body, and what content-type header to supply to the PUT.

I have the image I’ve loaded from the device as a base64 encoded string. Where do I go from there?

A working curl example would be useful.