Upload File using MDS WCF API RRS feed

  • General discussion

  • 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.


    Monday, April 30, 2012 12:50 PM

All replies

  • 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";


    Monday, April 30, 2012 1:48 PM
  • Excellent!

    Thanks for the coding sample :)

    But how about getting the image back out from MDS using the same API?   Using the mds admin tool I see that the data has been inserted correctly, but when I do an API call to get the data back out I only get data in the "Name" field.  The "Content" and "ContentType" is "null" :(



    Monday, January 13, 2014 2:36 PM
  • You need to use the EntityMemberAttributesGet operation to retrieve the contents of a file attribute. EntityMembersGet is designed to retrieve a collection of many members and therefore it would not make sense to retrieve every file for every row retrieved. In contrast, EntityMemberAttributesGet is designed to work with a single member and specific attributes of that member, and it was designed to retrieve the file content.

    Val Lovicz
    As the original creators of Microsoft MDS, Profisee's Master Data Maestro provides a range of enterprise-grade functionality to ensure MDS project success.

    • Edited by Val Lovicz Tuesday, January 14, 2014 8:20 PM correction
    Tuesday, January 14, 2014 8:05 PM
  • You sound like you have a solution, but am I missing something:

    In mds the file type attribute just stores the File Number. This number is the index in the mdm.tblFile where file is inside FileContent field.

    So if you want to insert or extract a file you would get it from mdm.tblFile based on the index...

    Monday, January 20, 2014 9:14 PM