It seems that Dan and I were puzzled by the same question on the same days, and we are getting the same solution!
I am using XML-RPC and the Magento API. I wrote this code as part of a larger class that reads image data from a file and makes it compatible with the Magento API.
internal void readFromFile(string fullImpgPath) { m_file.content = System.Convert.ToBase64String(System.IO.File.ReadAllBytes(fullImpgPath)); string ext = System.IO.Path.GetExtension(fullImpgPath).ToLower(); switch (ext) { case ".gif": m_file.mime = "image/gif"; break; case ".jpg": case ".jpeg": m_file.mime = "image/jpeg"; break; case ".png": m_file.mime = "image/png"; break; case ".bmp": m_file.mime = "image/bmp"; break; case ".tif": case ".tiff": m_file.mime = "image/tiff"; break; default: m_file.mime = "application/octet-stream"; break; } }
It is very important that the "content" must be of type string and must be obtained from bytes [] through a call to the system function Convert.ToBase64String(...) .
As for the MIME type, only "gif", "jpg" and "png" are supported since I found that I was looking at the Magento API code.
Giuseppe
source share