diff --git a/Infrastructure/CloudSdk/minio/MinioService.cs b/Infrastructure/CloudSdk/minio/MinioService.cs index fe62d53..0895b7c 100644 --- a/Infrastructure/CloudSdk/minio/MinioService.cs +++ b/Infrastructure/CloudSdk/minio/MinioService.cs @@ -11,6 +11,7 @@ public class MinioService { private IMinioClient _minioClient; public string _bucketName; + public string endPoint; public MinioService() { @@ -30,8 +31,9 @@ public class MinioService // 构建配置 var configuration = builder.Build(); _bucketName = configuration["Minio:BucketName"]; + endPoint = configuration["Minio:Endpoint"]; _minioClient = new MinioClient() - .WithEndpoint(configuration["Minio:Endpoint"]) + .WithEndpoint(endPoint) .WithCredentials(configuration["Minio:AccessKey"], configuration["Minio:SecretKey"]) .Build(); } @@ -134,7 +136,7 @@ public class MinioService } } - public async void UploadFile(IFormFile file, string bucketName) + public async Task UploadFile(IFormFile file, string bucketName) { try { @@ -166,6 +168,7 @@ public class MinioService .WithContentType("application/octet-stream"); //.WithContentType(file.ContentType); await _minioClient.PutObjectAsync(putArgs); + return ""; } catch (Exception ex) { diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 01e0fab..47d76c7 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -647,10 +647,9 @@ namespace OpenAuth.App.ServiceApp throw new NotImplementedException(); } - public void UploadFile(IFormFile xmlFile) + public Task UploadFile(IFormFile xmlFile) { - // todo - _minioService.UploadFile(xmlFile, ""); + return _minioService.UploadFile(xmlFile, ""); } } } \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs index 99f10a0..8d61ff7 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs @@ -241,6 +241,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return await _app.DeleteAirLine(id); } + // todo 已有的文件如何处理? /// /// 上传航线文件 /// @@ -253,8 +254,8 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers if (xmlFile == null || xmlFile.Length == 0) return BadRequest("文件为空"); - _app.UploadFile(xmlFile); - return Ok(new { message = "上传成功" }); + var path = await _app.UploadFile(xmlFile); + return Ok(new { message = "上传成功", path }); } /*/// /// 更新航线文件