api ปฏิเสธจ่ายเงิน get ไฟล์สมัครสอบ
This commit is contained in:
parent
9486ad160d
commit
5abeada4a6
32 changed files with 7513 additions and 394 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue