Hi,
I have a 9.1 On-Premise instance of Dynamics 365 which I am trying to add a File data type field to a custom entity. I hav added the field successfully and I am now trying to retrieve and read the contents of the file in the PostUpdate plugin.
I have the following C# code which I found from various supporting places which is supposed to work:
InitializeFileBlocksDownloadRequest initializeFile = new InitializeFileBlocksDownloadRequest();
initializeFile.FileAttributeName = CRMConstants.RECEIPTING_PAYMENTS_FILE;
initializeFile.Target = new EntityReference(CRMConstants.RECEIPTING_PAYMENTS_LOGICAL_NAME, receiptingPaymentsEntity.Id);
InitializeFileBlocksDownloadResponse initializeFileResponse = (InitializeFileBlocksDownloadResponse)service.Execute(initializeFile);
var fileContinuationToken = initializeFileResponse.FileContinuationToken;
// code to downlod the file.
DownloadBlockRequest downloadRequest = new DownloadBlockRequest();
downloadRequest.Offset = 0;
downloadRequest.BlockLength = (long)4 * 1024 * 1024; // can be max of 4 MB
downloadRequest.FileContinuationToken = fileContinuationToken;
DownloadBlockResponse downloadBlockResponse = (DownloadBlockResponse)service.Execute(downloadRequest);
The last line throws the error:
Downloading in multiple chunks is not supported for the files stored in the database.'
Has anyone got any ideas on what I am doing wrong or how to correct the code to avoid chunking?