I\'m attempting to upload images to a Magento site using the SOAP API with C#.
This is what I have so far, but it isn\'t working, no exceptions are thrown or anything bu
It seems that Dan and I have been puzzled in the same issue on the same days, and we get the same solution!
I'm using XML-RPC and the Magento API. I wrote this code as a part of a bigger class that read the image data from a file and makes it compatible with 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;
}
}
The very important thing is that the "content" must be of type string and
must be obtained from bytes[] through the call of the system function Convert.ToBase64String(...)
.
Concerning the MIME type of the image, only "gif", "jpg" and "png" are supported as I discovered looking inside the Magento API code.