สร้างรายการรับโอน ถ้าเป็นขรก.เดิมใช้รูปภาพจากทะเบียนประวัติ #1168
Some checks failed
release-dev / release-dev (push) Failing after 10s
Some checks failed
release-dev / release-dev (push) Failing after 10s
This commit is contained in:
parent
18be7bee37
commit
d6a3bdc8ba
3 changed files with 62 additions and 22 deletions
|
|
@ -155,6 +155,40 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<FormFile> GetImageToFormFileAsync(string refId)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var memoryStream = new MemoryStream();
|
||||
var request = new GetObjectRequest
|
||||
{
|
||||
BucketName = _bucketName,
|
||||
Key = refId
|
||||
};
|
||||
|
||||
using var response = await _s3Client.GetObjectAsync(request);
|
||||
using var responseStream = response.ResponseStream;
|
||||
|
||||
await responseStream.CopyToAsync(memoryStream);
|
||||
|
||||
var finalBytes = memoryStream.ToArray();
|
||||
|
||||
var finalStream = new MemoryStream(finalBytes);
|
||||
var fileName = Path.GetFileName(refId);
|
||||
var contentType = response.Headers.ContentType ?? "image/jpeg";
|
||||
|
||||
return new FormFile(finalStream, 0, finalStream.Length, "file", fileName)
|
||||
{
|
||||
Headers = new HeaderDictionary(),
|
||||
ContentType = contentType
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeleteFileAsync(Guid fileId)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue