1. minio添加重载上传方法

2. 航线上传添加文件夹前缀
3. 航线添加添加文件夹参数
4. 航线列表查询添加文件夹过滤参数
main
陈伟 2 months ago
parent 96758ef8c5
commit ab367a8726

@ -158,6 +158,7 @@ public class MinioService
{
objectName = objectName.Replace($"http://{endPoint}/{_bucketName}/", "");
}
var deleteargs = new RemoveObjectArgs().WithBucket(_bucketName).WithObject(objectName);
await _minioClient.RemoveObjectAsync(deleteargs);
Console.WriteLine($"File {objectName} deleted.");
@ -169,6 +170,11 @@ public class MinioService
}
public async Task<string> UploadFile(IFormFile file, string bucketName)
{
return await UploadFile(file, bucketName, "");
}
public async Task<string> UploadFile(IFormFile file, string bucketName, string prifix)
{
try
{
@ -188,7 +194,16 @@ public class MinioService
}
var suffix = Path.GetExtension(file.FileName);
var objectName = $"{GenerateId.GenerateOrderNumber()}{suffix}";
string objectName;
if (string.IsNullOrEmpty(prifix))
{
objectName = $"{GenerateId.GenerateOrderNumber()}{suffix}";
}
else
{
objectName = $"{prifix}/{GenerateId.GenerateOrderNumber()}{suffix}";
}
// 使用内存流上传
using var stream = new MemoryStream();
await file.CopyToAsync(stream);
@ -207,8 +222,9 @@ public class MinioService
})
.WithContentType("application/octet-stream");
//.WithContentType(file.ContentType);
await _minioClient.PutObjectAsync(putArgs);
return "http://" + endPoint + "/" + bucketName + "/" + objectName;
var result = await _minioClient.PutObjectAsync(putArgs);
Console.WriteLine("code :" + result.ResponseStatusCode);
return "http://" + endPoint + "/" + bucketName + "/" + objectName;
}
catch (Exception ex)
{

@ -20,4 +20,6 @@ public class AirLineListRequestPage : PageReq
/// 航线名称
/// </summary>
public string AirLineName { get; set; }
public string Folder { get; set; }
}

@ -504,6 +504,7 @@ namespace OpenAuth.App.ServiceApp
.WhereIF(!string.IsNullOrEmpty(req.key), a => a.AirLineName.Contains(req.key))
.WhereIF(!string.IsNullOrEmpty(req.AirLineName), a => a.AirLineName.Contains(req.AirLineName))
.WhereIF(!string.IsNullOrEmpty(req.AirLineType), a => a.AirLineType.Equals(req.AirLineType))
.WhereIF(!string.IsNullOrEmpty(req.Folder), (a) => a.Folder.Equals(req.Folder))
.OrderByIF(true, a => a.CreateTime, req.Ascending ? OrderByType.Asc : OrderByType.Desc)
.ToPageListAsync(req.page, req.limit, totalCount);
return new Response<PageInfo<List<LasaAirLine>>>
@ -948,9 +949,9 @@ namespace OpenAuth.App.ServiceApp
throw new NotImplementedException();
}
public Task<string> UploadFile(IFormFile xmlFile)
public Task<string> UploadFile(IFormFile xmlFile, string folder)
{
return _minioService.UploadFile(xmlFile, "");
return _minioService.UploadFile(xmlFile, "", folder);
}
#region 添加地图作业区域
@ -1403,7 +1404,7 @@ namespace OpenAuth.App.ServiceApp
#endregion
public async Task<Response<bool>> CreateAirLoneFolder(string folderName, string parentId)
public async Task<Response<bool>> CreateAirLineFolder(string folderName, string parentId)
{
LasaLineFolder folder = new LasaLineFolder()
{

@ -11,25 +11,28 @@ namespace OpenAuth.Repository.Domain
public class LasaAirLine
{
[SugarColumn(IsPrimaryKey = true, ColumnName = "Id")]
public string Id { get; set; } // 主键
public string AirLineName { get; set; } // 航线名称
public string AirLineType { get; set; } // 航线类型
public string UavId { get; set; } // 无人机 ID
public string FlyToFirstPointMode { get; set; } // 飞向首航点模式
public int SafeTakeoffAltitude { get; set; } // 安全起飞高度
public int SafeTakeoffSpeed { get; set; } // 飞向首航点速度
public double GlobalRouteSpeed { get; set; } // 全局航线速度
public string TaskCompletionAction { get; set; } // 任务完成动作
public string OutOfControlOption { get; set; } // 失控选项
public string TypeOfOutOfControlAction { get; set; } // 失控动作类型
public string GlobalWayPointType { get; set; } // 全局航点类型
public string PTZControlMode { get; set; } // 云台控制模式
public string AircraftYawAngleMode { get; set; } // 飞行器偏航角模式
public DateTime? CreateTime { get; set; } // 创建时间
public long CreateId { get; set; } // 创建人
public string Id { get; set; } // 主键
public string AirLineName { get; set; } // 航线名称
public string AirLineType { get; set; } // 航线类型
public string UavId { get; set; } // 无人机 ID
public string FlyToFirstPointMode { get; set; } // 飞向首航点模式
public int SafeTakeoffAltitude { get; set; } // 安全起飞高度
public int SafeTakeoffSpeed { get; set; } // 飞向首航点速度
public double GlobalRouteSpeed { get; set; } // 全局航线速度
public string TaskCompletionAction { get; set; } // 任务完成动作
public string OutOfControlOption { get; set; } // 失控选项
public string TypeOfOutOfControlAction { get; set; } // 失控动作类型
public string GlobalWayPointType { get; set; } // 全局航点类型
public string PTZControlMode { get; set; } // 云台控制模式
public string AircraftYawAngleMode { get; set; } // 飞行器偏航角模式
public DateTime? CreateTime { get; set; } // 创建时间
public long CreateId { get; set; } // 创建人
public string WPML { get; set; } // WPML 航线文件地址
public float? TaskOffLng { get; set; }
public float? TaskOffLat { get; set; }
public string Folder { get; set; }
}
}
}

@ -258,9 +258,9 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
// todo 删除文件夹
// todo 文件夹列表
[HttpPost]
public async Task<Response<bool>> CreateAirLoneFolder(string folderName, string parentId)
public async Task<Response<bool>> CreateAirLineFolder(string folderName, string parentId)
{
return await _app.CreateAirLoneFolder(folderName, parentId);
return await _app.CreateAirLineFolder(folderName, parentId);
}
/// <summary>
@ -344,20 +344,19 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
return await _app.DeleteAirLine(id);
}
// todo 已有的文件如何处理?
/// <summary>
/// 上传航线文件
/// </summary>
/// <param name="xmlFile"></param>
/// <param name="xmlFile">kmz文件</param>
/// <param name="folder">文件夹</param>
/// <returns></returns>
[HttpPost("upload")]
[AllowAnonymous]
public async Task<IActionResult> UploadXmlFile(IFormFile xmlFile)
public async Task<IActionResult> UploadXmlFile(IFormFile xmlFile,string folder)
{
if (xmlFile == null || xmlFile.Length == 0)
return BadRequest("文件为空");
var path = await _app.UploadFile(xmlFile);
var path = await _app.UploadFile(xmlFile,folder);
return Ok(new { message = "上传成功", path });
}
/*/// <summary>

Loading…
Cancel
Save