I'm trying to get the Stream of file that exists on sensenet through ClientAPI. But I didn't find any documentation about that. I also tried using the RestCaller SenseNET API Calls but I don't know how to get the input parameter FieldID... through the path of the file (ex: /Root/Sites/Test/file.txt)
I have an server api that encapsulates the sensenet content from the client application. So, the requests on sensenet are all on server side. I tried to get stream file with contentId... But It doesn't bring the ID of the Content.Result (object that brings the ID (I guess...)). For instance, the return is:
content = Id = 1016, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
Here's my code:
var fileId = SenseNet.Client.Content.LoadAsync(parentPath).Result.Id;
var req = RESTCaller.GetStreamRequest(fileId);
try
{
using (var response = await req.GetResponseAsync())
{
using (var stream = response.GetResponseStream())
{
using (var streamReader = new MemoryStream())
{
stream.CopyTo(streamReader);
return streamReader.ToArray();
}
}
}
}
catch (WebException webex)
{
throw await RESTCaller.GetClientExceptionAsync(webex, req.RequestUri.ToString());
}