fix uploading
This commit is contained in:
parent
c2515281d1
commit
a1696c38c7
@ -68,10 +68,7 @@ namespace FarmmapsApi.Services
|
|||||||
contentStream.ThrowIfNull(nameof(contentStream));
|
contentStream.ThrowIfNull(nameof(contentStream));
|
||||||
|
|
||||||
_streamLength = ContentStream.CanSeek ? ContentStream.Length : UnknownSize;
|
_streamLength = ContentStream.CanSeek ? ContentStream.Length : UnknownSize;
|
||||||
|
ChunkSize = 2 * 0x100000;
|
||||||
var twoMB = 2 * 0x100000;
|
|
||||||
ChunkSize = twoMB;
|
|
||||||
body.ChunkSize = ChunkSize;
|
|
||||||
Body = body;
|
Body = body;
|
||||||
|
|
||||||
Path = path;
|
Path = path;
|
||||||
|
@ -41,7 +41,14 @@ namespace FarmmapsApi.Services
|
|||||||
{
|
{
|
||||||
var startUpload = DateTime.UtcNow.AddSeconds(-3);
|
var startUpload = DateTime.UtcNow.AddSeconds(-3);
|
||||||
var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString,
|
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)
|
if (result.Progress.Status == UploadStatus.Failed)
|
||||||
return null;
|
return null;
|
||||||
@ -68,13 +75,16 @@ namespace FarmmapsApi.Services
|
|||||||
public async Task<Item> ShapeToGeotiff(Item shapeItem, int resolution = 1, params string[] inputLayerNames)
|
public async Task<Item> ShapeToGeotiff(Item shapeItem, int resolution = 1, params string[] inputLayerNames)
|
||||||
{
|
{
|
||||||
var startUpload = DateTime.UtcNow.AddSeconds(-3);
|
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();
|
request.attributes["resolution"] = resolution.ToString();
|
||||||
if(inputLayerNames.Length > 0)
|
if(inputLayerNames.Length > 0)
|
||||||
request.attributes["inputLayers"] = $"[{string.Join(",", inputLayerNames.Select(v => $"\"{v}\""))}]";
|
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,
|
return await FindChildItemAsync(shapeItem.ParentCode, GEOTIFF_PROCESSED_ITEMTYPE, shapeItem.Name,
|
||||||
i => i.Created >= startUpload &&
|
i => i.Created >= startUpload &&
|
||||||
i.Name.ToLower().Contains(shapeItem.Name.ToLower()));
|
i.Name.ToLower().Contains(shapeItem.Name.ToLower()));
|
||||||
|
@ -143,14 +143,13 @@ namespace FarmmapsVRApoten
|
|||||||
_logger.LogInformation($"Converting shape to geotiff");
|
_logger.LogInformation($"Converting shape to geotiff");
|
||||||
|
|
||||||
geotiffItem = await _generalService.ShapeToGeotiff(shapeItem);
|
geotiffItem = await _generalService.ShapeToGeotiff(shapeItem);
|
||||||
_logger.LogInformation($"ShapeToGeotiff_GeotiffItemcode: {geotiffItem.Code}");
|
|
||||||
|
|
||||||
|
|
||||||
if (geotiffItem == null) {
|
if (geotiffItem == null) {
|
||||||
_logger.LogError("Something went wrong with shape to geotiff transformation");
|
_logger.LogError("Something went wrong with shape to geotiff transformation");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation($"ShapeToGeotiff_GeotiffItemcode: {geotiffItem.Code}");
|
||||||
|
|
||||||
_logger.LogInformation("Downloading geotiff file");
|
_logger.LogInformation("Downloading geotiff file");
|
||||||
await _farmmapsApiService.DownloadItemAsync(geotiffItem.Code,
|
await _farmmapsApiService.DownloadItemAsync(geotiffItem.Code,
|
||||||
Path.Combine(DownloadFolder, $"VRApoten_inputGeotiff_{input.OutputFileName}.zip"));
|
Path.Combine(DownloadFolder, $"VRApoten_inputGeotiff_{input.OutputFileName}.zip"));
|
||||||
|
Loading…
Reference in New Issue
Block a user