forked from FarmMaps/FarmMapsApiClient
		
	can now specify geojson bounds for upload.
changed how to get agents for haulmkilling.
This commit is contained in:
		@@ -284,6 +284,7 @@ namespace FarmmapsApi.Services
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        /// <exception cref="FileNotFoundException"></exception>
 | 
			
		||||
        public async Task<UploadResults> UploadFile(string filePath, string parentItemCode,
 | 
			
		||||
            string geoJsonString = null,
 | 
			
		||||
            Action<IUploadProgress> progressCallback = null)
 | 
			
		||||
        {
 | 
			
		||||
            if (!File.Exists(filePath))
 | 
			
		||||
@@ -300,7 +301,8 @@ namespace FarmmapsApi.Services
 | 
			
		||||
            {
 | 
			
		||||
                Name = Path.GetFileName(filePath),
 | 
			
		||||
                ParentCode = parentItemCode,
 | 
			
		||||
                Size = uploadStream.Length
 | 
			
		||||
                Size = uploadStream.Length,
 | 
			
		||||
                Geometry = string.IsNullOrEmpty(geoJsonString) ? null : JObject.Parse(geoJsonString)
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            using var httpClient = CreateConfigurableHttpClient(_httpClient);
 | 
			
		||||
 
 | 
			
		||||
@@ -41,10 +41,10 @@ namespace FarmmapsApi.Services
 | 
			
		||||
            return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async Task<Item> UploadDataAsync(UserRoot root, string itemType, string filePath, string itemName)
 | 
			
		||||
        public async Task<Item> UploadDataAsync(UserRoot root, string itemType, string filePath, string itemName, string geoJsonString = null)
 | 
			
		||||
        {
 | 
			
		||||
            var startUpload = DateTime.UtcNow.AddSeconds(-3);
 | 
			
		||||
            var result = await _farmmapsApiService.UploadFile(filePath, root.Code,
 | 
			
		||||
            var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString,
 | 
			
		||||
                progress => _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}"));
 | 
			
		||||
 | 
			
		||||
            if (result.Progress.Status == UploadStatus.Failed)
 | 
			
		||||
@@ -55,10 +55,10 @@ namespace FarmmapsApi.Services
 | 
			
		||||
                     i.Name.ToLower().Contains(itemName.ToLower()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async Task<Item> UploadZipWithShapeAsync(UserRoot root, string filePath, string itemName)
 | 
			
		||||
        public async Task<Item> UploadZipWithShapeAsync(UserRoot root, string filePath, string itemName, string geoJsonString = null)
 | 
			
		||||
        {
 | 
			
		||||
            var startUpload = DateTime.UtcNow;
 | 
			
		||||
            var result = await _farmmapsApiService.UploadFile(filePath, root.Code,
 | 
			
		||||
            var startUpload = DateTime.UtcNow.AddSeconds(-3);
 | 
			
		||||
            var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString,
 | 
			
		||||
                progress => _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}"));
 | 
			
		||||
 | 
			
		||||
            if (result.Progress.Status == UploadStatus.Failed)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user