api ปฏิเสธจ่ายเงิน get ไฟล์สมัครสอบ

This commit is contained in:
Kittapath 2023-04-09 04:22:04 +07:00
parent 9486ad160d
commit 5abeada4a6
32 changed files with 7513 additions and 394 deletions

View file

@ -46,6 +46,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
this._bucketName = _configuration["MinIO:BucketName"] ?? "bma-recruit";
}
public static IConfigurationRoot Configuration
{
get
{
return new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
}
}
#endregion
#region " Methods "
@ -185,6 +196,34 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
}
}
public async Task<string> ImagesPath(Guid fileId)
{
if (fileId == null)
return "";
var doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == fileId);
if (doc == null)
throw new Exception(GlobalMessages.FileNotFoundOnServer);
var config = new AmazonS3Config
{
ServiceURL = Configuration.GetValue<string>("MinIO:Endpoint"),
ForcePathStyle = true
};
DateTime expires = DateTime.UtcNow.AddHours(6);
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
{
BucketName = _bucketName,
Key = doc?.ObjectRefId.ToString("D"),
Expires = expires,
};
string path = _s3Client.GetPreSignedURL(request);
return path;
}
#endregion
}
}