แก้ api fileImageCandidate
This commit is contained in:
parent
d16435c2c9
commit
9cf8135301
2 changed files with 68 additions and 85 deletions
|
|
@ -715,46 +715,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ตัวอย่างในการเขียน api เพื่อทำการ upload file
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพ ลาดในการทำงาน</response>
|
||||
// [HttpPost("upload"), DisableRequestSizeLimit]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK)]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
// [ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
// [ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
// [AllowAnonymous]
|
||||
// public async Task<ActionResult<ResponseObject>> 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)}")]
|
||||
/// อัปโหลดรูปถ่ายผู้สมัคร
|
||||
/// </summary>
|
||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่ออัปโหลดรูปถ่ายผู้สมัครสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("profile-image/{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteFile(Guid id)
|
||||
public async Task<ActionResult<ResponseObject>> UpdateProfileImageCandidateService(string examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _minioService.DeleteFileAsync(id);
|
||||
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||
{
|
||||
return Error(GlobalMessages.NoFileToUpload);
|
||||
}
|
||||
|
||||
var file = Request.Form.Files[0];
|
||||
await _candidateService.UpdateAsyncProfileImage(examId, file);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -764,30 +751,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
[HttpGet("download/{id:length(36)}")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// อัปเอกสารหลักฐาน
|
||||
/// </summary>
|
||||
|
|
@ -828,23 +791,23 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
/// <response code="200">เมื่อลบเอกสารหลักฐานสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("upload/{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteFileCandidateService(string documentId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _candidateService.DeleteAsyncDocument(documentId);
|
||||
// [HttpDelete("upload/{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK)]
|
||||
// [ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
// [ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
// public async Task<ActionResult<ResponseObject>> DeleteFileCandidateService(string documentId)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await _candidateService.DeleteAsyncDocument(documentId);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
// return Success();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return Error(ex);
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// โหลดไฟล์
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue