Upload File using MDS WCF API

Discussion Upload File using MDS WCF API

  • lundi 30 avril 2012 12:50
     
     

    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!


Toutes les réponses

  • lundi 30 avril 2012 13:48
     
     

    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!