diff --git a/FarmmapsApi/Services/FarmmapsUploader.cs b/FarmmapsApi/Services/FarmmapsUploader.cs index 1cae5fe..3a58827 100644 --- a/FarmmapsApi/Services/FarmmapsUploader.cs +++ b/FarmmapsApi/Services/FarmmapsUploader.cs @@ -68,10 +68,7 @@ namespace FarmmapsApi.Services contentStream.ThrowIfNull(nameof(contentStream)); _streamLength = ContentStream.CanSeek ? ContentStream.Length : UnknownSize; - - var twoMB = 2 * 0x100000; - ChunkSize = twoMB; - body.ChunkSize = ChunkSize; + ChunkSize = 2 * 0x100000; Body = body; Path = path; diff --git a/FarmmapsApi/Services/GeneralService.cs b/FarmmapsApi/Services/GeneralService.cs index 0d698b9..7027985 100644 --- a/FarmmapsApi/Services/GeneralService.cs +++ b/FarmmapsApi/Services/GeneralService.cs @@ -41,7 +41,14 @@ namespace FarmmapsApi.Services { var startUpload = DateTime.UtcNow.AddSeconds(-3); var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString, - progress => _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}")); + progress => + { + _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}"); + + if(progress.Status == UploadStatus.Failed && progress.Exception != null) + _logger.LogError(progress.Exception.Message ?? "No further error"); + + }); if (result.Progress.Status == UploadStatus.Failed) return null; @@ -68,13 +75,16 @@ namespace FarmmapsApi.Services public async Task ShapeToGeotiff(Item shapeItem, int resolution = 1, params string[] inputLayerNames) { var startUpload = DateTime.UtcNow.AddSeconds(-3); - await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff", request => + var taskStatus = await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff", request => { request.attributes["resolution"] = resolution.ToString(); if(inputLayerNames.Length > 0) request.attributes["inputLayers"] = $"[{string.Join(",", inputLayerNames.Select(v => $"\"{v}\""))}]"; }); + if (taskStatus.State == ItemTaskState.Error) + return null; + return await FindChildItemAsync(shapeItem.ParentCode, GEOTIFF_PROCESSED_ITEMTYPE, shapeItem.Name, i => i.Created >= startUpload && i.Name.ToLower().Contains(shapeItem.Name.ToLower())); diff --git a/FarmmapsPoten/PotenApplication.cs b/FarmmapsPoten/PotenApplication.cs index 7479bfb..91e27a9 100644 --- a/FarmmapsPoten/PotenApplication.cs +++ b/FarmmapsPoten/PotenApplication.cs @@ -143,13 +143,12 @@ namespace FarmmapsVRApoten _logger.LogInformation($"Converting shape to geotiff"); geotiffItem = await _generalService.ShapeToGeotiff(shapeItem); - _logger.LogInformation($"ShapeToGeotiff_GeotiffItemcode: {geotiffItem.Code}"); - - if (geotiffItem == null) { _logger.LogError("Something went wrong with shape to geotiff transformation"); return; } + + _logger.LogInformation($"ShapeToGeotiff_GeotiffItemcode: {geotiffItem.Code}"); _logger.LogInformation("Downloading geotiff file"); await _farmmapsApiService.DownloadItemAsync(geotiffItem.Code,