infoRouter DMS - Web Services API Documentation
DownloadDocument
Downloads a document in byte array format.
Syntax
[Visual Basic]
Public Shared Function DownloadDocument(ByVal AuthenticationTicket As String, _
Byval Path as string) as Byte()
Parameters

AuthenticationTicket

infoRouter Authentication Ticket

Path

A document path in the infoRouter to be downloaded.


Return Value
Returns the content of the document in a byte array.
Remarks
The caller must be the owner of the document or must have at least "Read" permissions on the document.
If this function returns zero (0) bytes then call the function "GetDownloadInfo" to get the error description.
Example
Public Sub DownloadDocument_Sample()

Const IRAuthenticationTicket As String = "sid-xxxxxxxxxxx"
Const IRDocPath As String = "/public/sample/ninepeople.jpg"
Const DownloadPath As String = "c:\temp\"

Dim IROBJ As InfoRouter.srv
Try
IROBJ = New InfoRouter.srv
Dim FileName As String = System.IO.Path.GetFileName(IRDocPath)
'call downloaddocument method to get bytearray
Dim buffer As Byte() = IROBJ.DownloadDocument(AuthenticationTicket, _
IRDocPath)
If IsArray(buffer) Then
Dim fs As System.IO.FileStream = New System.IO.FileStream( _
DownloadPath & FileName, _
System.IO.FileMode.Create, _
IO.FileAccess.Write)

Dim bw As System.IO.BinaryWriter = New System.IO.BinaryWriter(fs)
'write bytearray to the local path
bw.Write(buffer)
bw.Close()
fs.Close()
bw = Nothing
fs = Nothing

Console.WriteLine("Document content has been downloaded to the " & _
DownloadPath & FileName)
Else

'Calling the GetDownloadInfo function for the error

Dim xml_response As System.Xml.XmlElement = _
IROBJ.GetDownloadInfo(AuthenticationTicket, IRDocPath)

If Not xml_response Is Nothing Then
Console.WriteLine("The Document cannot be downloaded.")
Console.WriteLine(xml_response.GetAttribute("error"))
End If
xml_response = Nothing
End If

Catch EX As Exception
Console.WriteLine("error:" & EX.Message)
Finally
IROBJ = Nothing
End Try
End Sub
See Also
UploadDocument
Syntax based on infoRouter Document Management System Web Services API Version 7.0
Copyright() 1998-2003 Active Innovations, Inc.
infoRouter Document Management System