上传航线文件添加路径返回
parent
da3ed8b5d5
commit
3d11190388
|
|
@ -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<string> 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -647,10 +647,9 @@ namespace OpenAuth.App.ServiceApp
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UploadFile(IFormFile xmlFile)
|
||||
public Task<string> UploadFile(IFormFile xmlFile)
|
||||
{
|
||||
// todo
|
||||
_minioService.UploadFile(xmlFile, "");
|
||||
return _minioService.UploadFile(xmlFile, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -241,6 +241,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
return await _app.DeleteAirLine(id);
|
||||
}
|
||||
|
||||
// todo 已有的文件如何处理?
|
||||
/// <summary>
|
||||
/// 上传航线文件
|
||||
/// </summary>
|
||||
|
|
@ -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 });
|
||||
}
|
||||
/*/// <summary>
|
||||
/// 更新航线文件
|
||||
|
|
|
|||
Loading…
Reference in New Issue