Uploading a file
To upload a file to an Encyclopedia volume, you must identify the file to upload and the Encyclopedia volume in which to place the file. You can also specify how to work with existing versions of the file you upload. Using Actuate’s open server technology, you can upload third-party file types and native Actuate file types.
About ways of uploading a file
When you upload a file, the content streams to the Encyclopedia volume. You can stream a report with a SOAP message in two ways:
*Embed the file in the response.
In embedding a file, the application specifies the ContentLength in the HTTP header. If you use HTTP 1.0, you typically choose to embed the file.
*Send the file as a MIME attachment.
A MIME attachment transmits the contents of the file outside the boundary of the SOAP message.
A SOAP message with a MIME attachment consists of three parts:
*HTTP header
*Actuate SOAP message
*File attachment
The following example uses a MIME attachment and relevant Actuate Information Delivery API classes to build an application that uploads a file to an Encyclopedia volume.
Using UploadFile
Use the UploadFile class to upload a file to an Encyclopedia volume. The file content streams to BIRT iHub as an unchunked MIME attachment to the SOAP request. The UploadFile class contains the following attributes:
*NewFile is the NewFile object to upload.
*CopyFromLatestVersion is an array of strings used to copy one or more of the following properties from the latest version of the file, if one exists, to the version of the file that you upload:
*Description is a description of the file.
*Permissions, the access control list (ACL) specifying the users and roles that can access the file.
*ArchiveRule specifies the autoarchive rules for the file, which determine how BIRT iHub ages the file and when the file expires.
*Content is the Attachment object that specifies the content Id, content type, content length, content encoding, locale, and content data.
How to build an application that uploads a file
The following application derives from the code in the BIRT iHub Integration Technology example applications for the MS .NET Client. In this example application, AcUploadFile performs the following operations:
*Instantiates an ActuateAPIEx object for specifying the Actuate IDAPI SOAP header extension elements, such as AuthId
namespace Actuate
{
class AcUploadFile
{
ActuateAPI l_proxy;
ActuateAPIEx l_proxyEx= new ActuateAPIEx( );
l_proxyEx.Url = l_proxy.Url;
l_proxyEx.HeaderValue = new Header( );
l_proxyEx.HeaderValue.AuthId =
l_proxy.HeaderValue.AuthId;
*Prepares the UploadFile request by instantiating UploadFile, NewFile, and Attachment objects, and specifying the file name, content type, and content ID
UploadFile l_req = new UploadFile( );
l_req.NewFile = new NewFile( );
l_req.NewFile.Name = l_encFileName;
l_req.Content = new Attachment( );
l_req.Content.ContentType = "binary";
l_req.Content.ContentId = "Attachment";
*Opens the file for upload by constructing a FileStream object and passing the reference to the ActuateAPIEx object, handling any exception by outputting a message to the console
try
{
ActuateAPIEx.UploadStream =
new FileStream(l_localFileName, FileMode.Open);
}
catch(Exception e)
{
Console.WriteLine("Cannot open the file" + e.Message);
return;
}
*Performs the UploadFile administration operation by making an upload file proxy call and closing the file stream after the operation completes
UploadFileResponse l_res = null;
try
{
l_res = l_proxyEx.uploadFile(l_req);
}
catch(Exception e)
{
PrintExceptionDetails(e);
}
Console.WriteLine("Uploaded " + l_localFileName + " with
file id: "
+ l_res.FileId);
ActuateAPIEx.UploadStream.Close( );