diff --git a/src/Services/Storage/Implementation/DataRepository.cs b/src/Services/Storage/Implementation/DataRepository.cs index 7bfeb121..618b3f84 100644 --- a/src/Services/Storage/Implementation/DataRepository.cs +++ b/src/Services/Storage/Implementation/DataRepository.cs @@ -212,7 +212,7 @@ private string GetDataCollectionFolder() private static async Task ReadFileAsString(string path) { - Stream stream = await ReadFileAsStream(path); + using Stream stream = await ReadFileAsStream(path); using StreamReader reader = new StreamReader(stream); return await reader.ReadToEndAsync(); } diff --git a/src/Services/Storage/Implementation/DataService.cs b/src/Services/Storage/Implementation/DataService.cs index f209bee3..e4b010c2 100644 --- a/src/Services/Storage/Implementation/DataService.cs +++ b/src/Services/Storage/Implementation/DataService.cs @@ -42,7 +42,7 @@ public Task StartFileScan(Instance instance, DataType dataType, DataElement data return (null, new ServiceError(404, $"DataElement not found, dataElementId: {dataElementId}")); } - Stream filestream = await _dataRepository.ReadDataFromStorage(org, dataElement.BlobStoragePath); + using Stream filestream = await _dataRepository.ReadDataFromStorage(org, dataElement.BlobStoragePath); if (filestream == null || !filestream.CanRead) { return (null, new ServiceError(404, $"Failed reading file, dataElementId: {dataElementId}"));