snack-sdk adding an image asset

I’m using the snack-sdk’s SnackSession to upload code files and its working great. I now want to upload an image as an asset, but the image is broken when I view it in the snack.

I assume what I’m doing wrong is populating the “contents” property with data in the wrong format. Since an image in binary, I tried passing it an array of integers for the bytes of the image file. I’ve also tried passing it the string that I get when I open the image in notepad. Both ways end up with just a broken image in the snack.

contents: [137, 80, 78, 71, 13, … ]

contents: "�PNG\r\n\u001a\n\u0000\u000 … "

What is the right way to upload an image asset using the snack-sdk?

Thank you for taking the time to help.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.