Uploads a new document or creates a new version of an existing document in byte array format to the specified path - - UploadDocument


Visual Basic (declaration)
Public Function UploadDocument( _ 
ByVal AuthenticationTicket as String, _ ByVal Path as String, _ ByVal FileContent as Byte()) as XmlNode

C# (declaration)
public XmlNode UploadDocument( 
string AuthenticationTicket, string Path, byte[] FileContent)


    string inforouter ticket
    string An infoRouter document path that to be created or updated
    byte[] The Content of the file. The Content must be in the format of the byte array.

Return Value

returns xml fragment.
<response success="true" error="">

if success = "true", the document has been uploaded.
if success = "false", the error attribute returns the error description.


The caller must have at least "Add" permissions on the folder.
If the specified path does not exist, the path will be created.
If a document with the same name already exists in the same path, a new version of the existing document will be created.
This method is usefull when the documents are relatively small.
Instead of this function use UploadDocumentwWithHandler method for large files.

minus gif Example

Visual Basic Example
Option Explicit On
Option Strict On

Module Module_UploadDocument

    Sub UploadDocument(ByVal ServiceURL As String, ByVal AuthenticationTicket As String)

        Const uploadpath As String = "/TestDomain/sample/s.doc"
        Const LocalFilePath As String = "c:\temp\SummerPlan.doc"

        Dim IR_OBJ As InfoRouter.srv

            If System.IO.File.Exists(LocalFilePath) Then
                Dim FileName As String = System.IO.Path.GetFileName(LocalFilePath)
                Dim buffer() As Byte

                IR_OBJ = New InfoRouter.srv
                IR_OBJ.Url = ServiceURL

                'create byte array to upload
                Dim fs As System.IO.FileStream = New System.IO.FileStream(LocalFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
                Dim br As System.IO.BinaryReader = New System.IO.BinaryReader(fs) ' create a BinaryReader
                buffer = br.ReadBytes(Convert.ToInt32(fs.Length))
                br = Nothing
                fs = Nothing

                'call upload method
                Dim xml_response As System.Xml.XmlNode = IR_OBJ.UploadDocument(AuthenticationTicket, uploadpath, buffer)

                'check response xml if any error occured.
                If xml_response.Attributes("success").Value.ToUpperInvariant() = "TRUE" Then
                    Console.WriteLine("The Document has been uploaded successfully.")
                    Console.WriteLine("The Document cannot be uploaded.")
                    Console.WriteLine("ERROR:" & xml_response.Attributes("error").Value)
                End If
                xml_response = Nothing
                Console.WriteLine("ERROR:Local file not found.")
            End If
        Catch ex As Exception
            Console.WriteLine("ERROR:" + ex.Message)
            IR_OBJ = Nothing
        End Try
    End Sub

End Module