CustomerDataService.UploadData Method
CustomerDataService.UploadData Method
Uploads the point-of-interest data. You can use this method to upload data in multiple chunks. This method returns the number of bytes that were uploaded in the current call.
Public Function UploadData (jobID As System.String, buffer As System.Byte(), bytesPreviouslyUploaded As System.Int64) As System.Int64
[C#]
public System.Int64 UploadData (System.String jobID, System.Byte[] buffer, System.Int64 bytesPreviouslyUploaded);
Parameters
- jobID
A unique ID that represents the data upload job.
- buffer
The point-of-interest data that is being uploaded to the MapPoint Web Service servers. The data is uploaded as an array of bytes. You can also upload the data in multiple chunks. The maximum size per chunk is 1 megabyte (MB).
- bytesPreviouslyUploaded
The number of bytes uploaded for the job represented by the job ID. The value of this parameter is 0 if you are uploading all of the data in one call.
Remarks
If you are uploading data in one call, set the bytesPreviouslyUploaded parameter to 0.
If you are uploading the data in multiple chunks, this parameter value must match the cumulative sum of all individual uploads for the current job. For example, if you have 10 kilobytes (KB) of data that you want to upload, the value of the bytesPreviouslyUploaded is 0 if you upload all 10 KB in one call to UploadData. However, if you decide to upload the same 10 KB of data in five chunks of 2 KB each, the values of the bytesPreviouslyUploaded parameter should be 0, 2000, 4000, 6000, and 8000 in corresponding consecutive calls to UploadData.
Successful completion of this method call does not load or process your data. You need to explicitly call the FinishUpload method to upload your points of interest into your data source. Always set your data upload proxy PreAuthenticate property to true (True in Visual Basic .NET) to avoid any errors during the data upload process.
The data can be uploaded in the following formats:
Text file format (tab delimited).
XML file format. The XML file should be exported from a Microsoft Access database along with a schema embedded in the main XML document.
Example
[Visual Basic]
'Create an instance of the customer data service proxy.
Dim custDataService As CustomerDataService = New CustomerDataService
'Assign your credentials.
custDataService.Credentials = _
New NetworkCredential(myUserName, mySecurePassword, myDomainName)
'Set PreAuthenticate to True
custDataService.PreAuthenticate = True
Try
'Get the contents from your POI file
Dim streamReader As StreamReader = New StreamReader(myPOITextFilePath)
Dim content As String = streamReader.ReadToEnd()
streamReader.Close()
'Convert the string content into an array of bytes.
Dim buffer As Byte() = Encoding.UTF8.GetBytes(content)
'Now upload the POI data.
Dim numberofbytes As Long = custDataService.UploadData(myJobID, buffer, 0)
Catch e As Exception
Dim message As String = e.Message
'Do your exception handling here.
End Try
[C#]
//Create an instance of the customer data service proxy.
CustomerDataService cds = new CustomerDataService();
//Assign your credentials.
cds.Credentials = new System.Net.NetworkCredential(myUserName,
mySecurePassword,
myDomainName);
//Set PreAuthenticate to true
cds.PreAuthenticate = true;
try
{
string POIdata = string.Empty;
//Get the contents from your POI file
System.IO.StreamReader sr = new StreamReader(myPOITextFilePath);
POIdata = sr.ReadToEnd();
sr.Close();
//Convert the string content into an array of bytes.
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(POIdata);
//Now upload the POI data.
long uploadedbytes = cds.UploadData(myJobID, buffer, 0);
}
catch(Exception ex)
{
string message = ex.Message;
//Do your exception handling here.
}