Import images through the API

We are trying out importing images through the API, but haven't had any luck. Has anyone already tried this? Is there an import function or any function specific to images?

string myEdt1 = "EDTXML";
string guidid = "GUID-"+Guid.NewGuid().ToString();
string version = "1";
string xmlMetadata = "<ishfields>" +
"<ishfield name='FTITLE' level='logical'>New Image</ishfield>" +
"<ishfield name='DOC-LANGUAGE' level='lng'>en-US</ishfield>" +
"<ishfield name='FSTATUS' level='lng'>Draft</ishfield>" +
"</ishfields>";
string someUrl = "">www.google.com/.../ps_logo2.png";

using (var webClient = new WebClient())
{
byte[] imageBytes = webClient.DownloadData(someUrl);
//Create image
userClientDocumentObj.Create(2521468, "ISHIllustration", ref guidid, ref version, "en-US", "Low",
xmlMetadata, myEdt1, imageBytes);
}

Parents
  • Hi Dave,

    Thank you changed to EDTPNG might have done the trick, change the code to the following .

    string myEdt1 = "EDTPNG";
    WebClient wc = new WebClient();
    byte[] bytes = wc.DownloadData(someUrl);
    MemoryStream ms = new MemoryStream(bytes);
    System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
    using (Image image = Image.FromStream(ms))
    {
    using (MemoryStream m = new MemoryStream())
    {
    image.Save(m, image.RawFormat);
    byte[] imageBytes = m.ToArray();
    m.Read(imageBytes, 0, (int)System.Convert.ToInt64(m.Length));
    bytes = imageBytes;
    m.Close();
    m.Dispose();
    }
    }
    userClientDocumentObj.Create(2878821, "ISHIllustration", ref guidid, ref version, language, "Default", xmlMetadata, myEdt1, bytes);

Reply
  • Hi Dave,

    Thank you changed to EDTPNG might have done the trick, change the code to the following .

    string myEdt1 = "EDTPNG";
    WebClient wc = new WebClient();
    byte[] bytes = wc.DownloadData(someUrl);
    MemoryStream ms = new MemoryStream(bytes);
    System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
    using (Image image = Image.FromStream(ms))
    {
    using (MemoryStream m = new MemoryStream())
    {
    image.Save(m, image.RawFormat);
    byte[] imageBytes = m.ToArray();
    m.Read(imageBytes, 0, (int)System.Convert.ToInt64(m.Length));
    bytes = imageBytes;
    m.Close();
    m.Dispose();
    }
    }
    userClientDocumentObj.Create(2878821, "ISHIllustration", ref guidid, ref version, language, "Default", xmlMetadata, myEdt1, bytes);

Children
No Data