Upload Manager
The Upload Manager web service provides methods for uploading client files to the Data8 system ready for cleansing.
The web service definition is available at
https://webservices.data-8.co.uk/batch/v1.0/uploadmanager.asmx?WSDL.
In order to upload a file, the StartUpload method must be called first to obtain a unique
identifier for the file to be uploaded. The UploadBlock method can then be called one or more
times to upload data from the file, and finally the FinishUpload method must be called to
indicate that all the data from the file has been uploaded.
The unique identifier for the file retrieved from the StartUpload method must be retained as it is required by the
SubmitJob method to start the data cleansing process on the uploaded data.
-
StartUpload
Begin uploading a new file for cleansing.
-
UploadBlock
Upload a block of data from a file for cleansing.
-
FinishUpload
Indicate that all the data from a file has been uploaded.
The following code sample illustrates how to upload a file for cleansing.
/// <summary>
/// Uploads a file to Data8 for cleansing.
/// </summary>
/// <param name="path">The path of the file to upload.</param>
/// <returns>The ID of the file to use to submit the file for cleansing.</returns>
private int UploadFile(string path)
{
// Start the upload and get the identifier for the file.
UploadManager proxy = new UploadManager();
int id = proxy.StartUpload(Username, Password);
byte[] buf = new byte[4096];
using (Stream fs = File.OpenRead(path))
{
// Upload the file in chunks of 4KB.
while (true)
{
int read = fs.Read(buf, 0, buf.Length);
if (read == 0)
break; // We've read the entire file.
else if (read < buf.Length)
Array.Resize(ref buf, read); // We haven't read the full 4KB.
// Upload the data to Data8.
proxy.UploadBlock(Username, Password, id, buf);
}
// Finished the upload.
proxy.FinishUpload(Username, Password, id, fs.Length);
}
return id;
}
Foundation Technology documentation overview