Sample Code - Sync-upload
To manage sync-upload requests in your environment, optional content changes to the file can be made.
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace ApiClientSample
{
static classProgram
{
static void Main()
{
string disarmerAddress = "https://support-va/disarmer/api/disarmer/v4/upload-sync"; //Reference 1
string bearerToken =
"eyJhbGciOiJSUzI1NiIsImtpZCI6IkIwQTVFNEZFMDI5QjA3RDhCMzkwRTFFRkYyRjQ1ODZGMTQzODUwQjciLCJ0eXAiOiJKV1QifQ.eyJ1bmlxdWVfbmFtZSI6Im9tcml0ZXN0aW5ncG9zdG1hbiIsImdyb3Vwc2lkIjoiVm90aXJvSW50ZXJuYWxTZXJ2aWNlcyIsInJvbGUiOiJBZG1pbmlzdHJhdG9yIiwianRpIjoiNjI5OWVmMjItNDk2YS00M2Y5LWFmNDAtMjAzZDQyNTRlNGMwIiwibmJmIjoxNTk1MTQyNjc0LCJleHAiOjE4ODAxMzk2MDAsImlhdCI6MTU5NTE0MjY3NH0.TCheBCwie4heCf4v8cIOJ-aT9gbVYuymvFPQoloQWUet5xyp08setMk8pTCPIgF3hWfhgo0MU22EVAHZn506oFGF7KUeNQk2LAQMFqXaNUG1b3D2Xlmn5PNG-GVxvWbageqXC-5bDtXAsPV0QFjV0nl0tYXyKnWIgmbXErgbXzCiRFhrDeEew1FuvW_VU6HEH6sCdkiGlGnL0Q_-O5vdOqKWk5WUFRyT2S5VR5rxO_ezWKLfMTJXPUTJl2sBDLiuk_qLmWXep7LUy6fzuSPScEsWqShpWT6fl2BEpSeqmItVjMaLOVUN8KhKgSkTTzACtAGa8zWuwncJ0PdmIXTKUg"; //Reference 2
string filePath = @"C:\Users\omri.matari\Downloads\virtual-systems-datasheet.pdf"; //Reference 3
UploadFile(filePath, bearerToken, disarmerAddress).Wait();
}
private static async Task UploadFile(string filePath, string bearerToken, string disarmerAddress)
{
using (Stream fileStream = File.OpenRead(filePath))
{
var formData = new MultipartFormDataContent
{
{
new StreamContent(fileStream),
"file",
Uri.EscapeDataString(Path.GetFileName(filePath)) //Support spaces + any non-english characters in FileName
},
{
new StringContent("{\"PolicyName\":\"Default Policy\",\"ChannelType\":\"FileConnector\",\"ChannelId\":\"30acc6eb-16d9-4133-ae43-0f5b6d40a318\",\"ChannelName\":\"API\"}"), // Reference 4
"properties"
}
};
using (formData)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
HttpResponseMessage httpResponseMessage = await client.PostAsync(disarmerAddress, formData)
.ConfigureAwait(false);
httpResponseMessage.EnsureSuccessStatusCode();
string result = await httpResponseMessage.Content.ReadAsStringAsync()
.ConfigureAwait(false);
Console.WriteLine(result);
}
}
}
}
}
}
Reference | Parameter | Description | ||||||
---|---|---|---|---|---|---|---|---|
1 | disarmerAddress | This is the address of your virtual appliance. Change the address used in the file to match your installation address. In the code example, change support-va to the name of your VA. | ||||||
2 | bearerToken
| Change the Token to provide authentication to Votiro Cloud. | ||||||
3 | filePath | Set the file path to the area where download files will be located in your environment. | ||||||
4 | PolicyName | Define the policy, changing the name. Additional fields for changing settings for are (optional):
Note Channel Type must remain set as "FileConnector". |
Comments
0 comments
Please sign in to leave a comment.