Discussion Upload File using MDS WCF API

  • Monday, April 30, 2012 12:50 PM
     
     

    I have a field of File Type in my Entity. How can I upload file using WCF API?

    I tried to create a new Entity Member and added the following attribute in the member attributes collection

    Attribute att = new Attribute();
    att.Identifier = new Identifier();
    att.Identifier.Name = "Image";

    att.Value = bytes;

    In attribute value I tried to pass the bytes array of an image, also tried Encoding.ASCII.GetString(bytes); as attribute value, but none of them works.

    With byte array i get the following exception "Conversion failed when converting the nvarchar value 'System.Byte[]' to data type int." and in case of ASCII string i get "A database error has occurred. Contact your system administrator." error.

    There is lack of documentation and samples.

    Please let me know if someone tried it out.

    Thanks!


All Replies

  • Monday, April 30, 2012 1:48 PM
     
     

    I solved it now finally.

    here is the code

                att.Type = AttributeValueType.File;            
                att.Value = new FileAttribute();
                (att.Value as FileAttribute).Content = bytes;
                (att.Value as FileAttribute).Name = "refresh.png";

    Thanks!