上传航线文件添加路径返回
parent
da3ed8b5d5
commit
3d11190388
|
|
@ -11,6 +11,7 @@ public class MinioService
|
||||||
{
|
{
|
||||||
private IMinioClient _minioClient;
|
private IMinioClient _minioClient;
|
||||||
public string _bucketName;
|
public string _bucketName;
|
||||||
|
public string endPoint;
|
||||||
|
|
||||||
public MinioService()
|
public MinioService()
|
||||||
{
|
{
|
||||||
|
|
@ -30,8 +31,9 @@ public class MinioService
|
||||||
// 构建配置
|
// 构建配置
|
||||||
var configuration = builder.Build();
|
var configuration = builder.Build();
|
||||||
_bucketName = configuration["Minio:BucketName"];
|
_bucketName = configuration["Minio:BucketName"];
|
||||||
|
endPoint = configuration["Minio:Endpoint"];
|
||||||
_minioClient = new MinioClient()
|
_minioClient = new MinioClient()
|
||||||
.WithEndpoint(configuration["Minio:Endpoint"])
|
.WithEndpoint(endPoint)
|
||||||
.WithCredentials(configuration["Minio:AccessKey"], configuration["Minio:SecretKey"])
|
.WithCredentials(configuration["Minio:AccessKey"], configuration["Minio:SecretKey"])
|
||||||
.Build();
|
.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
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -166,6 +168,7 @@ public class MinioService
|
||||||
.WithContentType("application/octet-stream");
|
.WithContentType("application/octet-stream");
|
||||||
//.WithContentType(file.ContentType);
|
//.WithContentType(file.ContentType);
|
||||||
await _minioClient.PutObjectAsync(putArgs);
|
await _minioClient.PutObjectAsync(putArgs);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -647,10 +647,9 @@ namespace OpenAuth.App.ServiceApp
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UploadFile(IFormFile xmlFile)
|
public Task<string> UploadFile(IFormFile xmlFile)
|
||||||
{
|
{
|
||||||
// todo
|
return _minioService.UploadFile(xmlFile, "");
|
||||||
_minioService.UploadFile(xmlFile, "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -241,6 +241,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||||
return await _app.DeleteAirLine(id);
|
return await _app.DeleteAirLine(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo 已有的文件如何处理?
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传航线文件
|
/// 上传航线文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -253,8 +254,8 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||||
if (xmlFile == null || xmlFile.Length == 0)
|
if (xmlFile == null || xmlFile.Length == 0)
|
||||||
return BadRequest("文件为空");
|
return BadRequest("文件为空");
|
||||||
|
|
||||||
_app.UploadFile(xmlFile);
|
var path = await _app.UploadFile(xmlFile);
|
||||||
return Ok(new { message = "上传成功" });
|
return Ok(new { message = "上传成功", path });
|
||||||
}
|
}
|
||||||
/*/// <summary>
|
/*/// <summary>
|
||||||
/// 更新航线文件
|
/// 更新航线文件
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue