public async Task<string> UploadDataAsync<T>(CloudBlobContainer container, string relativeUrl, List<T> reportData, string mimeType, string data, ILogger log)
{
string absoluteUri = string.Empty;
byte[] bytes = Encoding.ASCII.GetBytes(data);
using (var ms = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(ms))
{
sw.Write(data);
sw.Flush();
ms.Position = 0;
CloudAppendBlob blob;
blob = container.GetAppendBlobReference(relativeUrl);
if (await blob.ExistsAsync())
{
await blob.AppendBlockAsync(ms);
absoluteUri = blob.StorageUri.PrimaryUri.AbsoluteUri;
}
else
{
CloudAppendBlob appBlob = await CreateEmptyFileAsync(container, relativeUrl, reportData, mimeType, log);
await appBlob.AppendBlockAsync(ms);
absoluteUri = appBlob.StorageUri.PrimaryUri.AbsoluteUri;
}
}
}
return absoluteUri;
}
Getting this Exception -
Microsoft.WindowsAzure.Storage.StorageException: 'The request body is too large and exceeds the maximum permissible limit.' [External Code] PDCGeoTabFunction.Services.UploadService.UploadDataAsync(Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer, string, System.Collections.Generic.List, string, string, Microsoft.Extensions.Logging.ILogger) in UploadService.cs [External Code] PDCGeoTabFunction.Services.SyncGeoTabDataService.GetZone(Geotab.Checkmate.API, string, string, string, Microsoft.Extensions.Logging.ILogger, string, string, string, string, System.Collections.Generic.List<Geotab.Checkmate.ObjectModel.Zone>) in SyncGeoTabDataService.cs
Please help.
CodePudding user response:
Most likely you are getting this error is because the data that you are trying to upload is more than 4MB. The request payload size of each append operation can be a maximum of 4MB.
From REST API documentation
:
Append Block uploads a block to the end of an existing append blob. The block of data is immediately available once the call succeeds on the server. A block may be up to 4 MiB in size.
Please split your data in such a way that each call to AppendBlockAsync
is not uploading data more than 4MB.