FRAMES | NO FRAMES
UploadData Method

Uploads a zipped folder to the repository.

Availability: Business Analyst Server.

string[] UploadData ( 
    string  WorkspaceName, 
    string  ProjectName, 
    string  FileUrl, 
    bool    OverwriteAll 
);

Parameter Description
WorkspaceName Workspace name. Type String.
ProjectName Project name. Type String,
FileUrl URL to a zip-archive with folder contents already uploaded to the ArcGIS Server virtual output directory. Type String.
OverwriteAll Overwrite any existing content. Type Boolean.

Returns

Variable of type String[] containing upload results

Remarks

The upload process consists of two steps. At the first step, you should upload in some way a zip-archive with folder contents to the ArcGIS Server virtual output directory. At the last step, you can upload the contents of this archive to the Business Analyst Server repository using this method.

The archive for upload can contain one or more repository folders. The resulting array contains a value per a repository folder uploaded. The "true" value means the successful upload of a folder. To ensure that the upload operation successfully completes, you need to test all values of the returned array to be "true".

Examples

The example below uploads a local contents to the Business Analyst Server Repository. This example assumes you have a compressed project folder accessed at "C:\Data\CustomData.zip". After execution, the contents of the uploaded archive will be decompressed and available in the Custom Data folder of the Default Project of the Default Workspace of the repository. See the DownloadData example for downloading the Custom Data folder.

To download a sample CustomData.zip archive containing the "customers" table item, click the link below or right click this link and choose "Save as..." in the pop-up menu.

Download the CustomData.zip archive

C#
// Instantiate the BAServerHelper class to access analysis methods
BAServerHelper baServerHelper = new BAServerHelper();
 
string localPath = @"C:\Data\CustomData.zip"; // Local path to the compressed folder
 
// ========= STEP 1: Upload a compressed folder to the ArcGIS Server output directory
 
// Get an URL to a unique filename at the ArcGIS Server output directory.
// This filename contains a unique GUID and has the ".zip" extension.
string url = baServerHelper.GetUniqueFileName();
 
using (System.IO.FileStream output = System.IO.File.OpenRead(localPath))
{
    // Prepare a web request for uploading the file
    System.Net.WebRequest request = System.Net.HttpWebRequest.Create(url);
    request.Method = System.Net.WebRequestMethods.Http.Put;
    request.ContentLength = output.Length;
    request.ContentType = "application/x-www-form-urlencoded";
    request.Credentials = System.Net.CredentialCache.DefaultCredentials;
    request.Timeout = 300000; // 300,000 milliseconds (5 minutes)
 
    // Send the file to the server
    using (System.IO.Stream requestStream = request.GetRequestStream())
    {
        byte[] buffer = new byte[1024];
        int count;
        while ((count = output.Read(buffer, 0, buffer.Length)) > 0)
            requestStream.Write(buffer, 0, count);
    }
    request.GetResponse(); // This operation completes the request
}
 
// ========= STEP 2: Upload the compressed folder to the Business Analyst Server Repository
 
string project = "Default Project";
string workspace = "Default Workspace";
bool overwriteAll = true;
 
bool result = baServerHelper.UploadData(workspace, project, url, overwriteAll);

See Also