14

Due to a limitation with the HTTPClient implementation in Business Central, payloads larger than 150 MiB will fail to download. Because the AFS and BS APIs use the HTTPClient as their method of communicating with the service, this means that any attempt to download a file from an Azure File Share or Blob Container where the file is larger than 150MiB will result in an error despite the fact that both BC and Azure are able to handle files with much larger contents.


The Azure File Service REST API for Get File https://learn.microsoft.com/en-us/rest/api/storageservices/get-file and Blob Service REST API for Get Blob https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob both support the x-ms-range header property that allows a range of bytes to be read from the blob or file.


In this idea, the APIs should be written to check the size of the file being requested and if it is greater than the limit supported by the BC HTTPClient, it should use the x-ms-range header property to make a series of requests to download the file in chunks until the full file has been retrieved. Then the results can be returned back to the caller as a single stream of data.


The maximum size of files in blob storage or file share is so large (multiple TiB), it is not a practical ceiling. Instead, we should use the limit defined by BLOB fields in BC which is 2GiB as the cut-off. I think that is reasonable to set this limit as any file that is downloaded that is larger than this size could not be stored in BC and therefore should not be allowed. If an attempt to get a file that is larger than this size is made, the system should throw a suitable error message such as "File could not be downloaded as the file size exceeds the maximum allowed."



Category: Development
STATUS DETAILS
New