OpcUaClient.FileModel Write
Posted: 26 May 2021, 10:36
Hello,
I have implemented a short file transfer client example with .NET OPC UA SDK (code see below).
I create FileModel object and set the servers file node id. Then I split large file into chunks because the message size is limited to 16MB.
But on file.Write I get the following exception:
StatusException Message: "Write failed because the resulting size of the file would exceed the {0} byte limits set by the server."
What am I doing wrong? MaxFileSize on server side (FileModel) is set to 250 MB and my file is a lot smaller.
I have implemented a short file transfer client example with .NET OPC UA SDK (code see below).
I create FileModel object and set the servers file node id. Then I split large file into chunks because the message size is limited to 16MB.
But on file.Write I get the following exception:
StatusException Message: "Write failed because the resulting size of the file would exceed the {0} byte limits set by the server."
What am I doing wrong? MaxFileSize on server side (FileModel) is set to 250 MB and my file is a lot smaller.
Code: Select all
public void WriteFile(NodeId fileNodeId, uint fileHandle, byte[] data)
{
FileModel file = new FileModel(session);
file.FileNodeId = fileNodeId;
// split on groups with each 15.000.000 items each
byte[][] chunks = data
.Select((s, i) => new { Value = s, Index = i })
.GroupBy(x => x.Index / 15000000)
.Select(grp => grp.Select(x => x.Value).ToArray())
.ToArray();
for (int i = 0; i < chunks.Length; i++)
{
file.Write(fileHandle, chunks[i], 0);
}
file.Close(fileHandle);
}