diff --git a/Controllers/CandidateController.cs b/Controllers/CandidateController.cs
index e8f9c6c..a1b7327 100644
--- a/Controllers/CandidateController.cs
+++ b/Controllers/CandidateController.cs
@@ -19,7 +19,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
#region " Fields "
private readonly CandidateService _candidateService;
-
+ private readonly MinIOService _minioService;
#endregion
#region " Constructor and Destructor "
@@ -712,6 +712,78 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
return Error(ex);
}
}
+ ///
+ /// ตัวอย่างในการเขียน api เพื่อทำการ upload file
+ ///
+ ///
+ /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพ ลาดในการทำงาน
+ // [HttpPost("upload"), DisableRequestSizeLimit]
+ // [ProducesResponseType(StatusCodes.Status200OK)]
+ // [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ // [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ // [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ // [AllowAnonymous]
+ // public async Task> UploadFile()
+ // {
+ // try
+ // {
+ // if (Request.Form.Files == null || Request.Form.Files.Count == 0)
+ // {
+ // return Error(GlobalMessages.NoFileToUpload);
+ // }
+
+ // var file = Request.Form.Files[0];
+ // var doc = await _minioService.UploadFileAsync(file);
+
+ // return Success(doc);
+ // }
+ // catch (Exception ex)
+ // {
+ // return Error(ex);
+ // }
+ // }
+ [HttpGet("delete/{id:length(36)}")]
+ [AllowAnonymous]
+ public async Task> DeleteFile(Guid id)
+ {
+ try
+ {
+ await _minioService.DeleteFileAsync(id);
+
+ return Success();
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
+ [HttpGet("download/{id:length(36)}")]
+ [AllowAnonymous]
+ public async Task> DownloadFile(Guid id)
+ {
+ try
+ {
+ var file_data = await _minioService.DownloadFileAsync(id);
+
+ Response.Headers["Content-Disposition"] = $"inline; filename={file_data.FileName}";
+
+ var ret = new FileContentResult(file_data.FileContent, file_data.FileType)
+ {
+ FileDownloadName = file_data.FileName
+ };
+
+ return ret;
+ }
+ catch (Exception ex)
+ {
+ return Error(ex);
+ }
+ }
+
#endregion
}