forked from MDCPS/DamageAssessment_Backend
attachment and doculinks url changes
This commit is contained in:
@ -111,7 +111,31 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get all documents.
|
||||
/// download an existing attachment.
|
||||
/// </summary>
|
||||
[Authorize(Roles = "admin")]
|
||||
[HttpGet("doculinks/download/{id}")]
|
||||
public async Task<IActionResult> downloadfile1(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await this.documentsProvider.GetDownloadAttachmentAsync(id);
|
||||
if (!result.IsSuccess)
|
||||
return NotFound();
|
||||
byte[] fileContent = await uploadService.DownloadFile(result.DoculinkAttachments.Path);
|
||||
if (fileContent == null || fileContent.Length == 0)
|
||||
return NotFound();
|
||||
var contentType = "application/octet-stream";
|
||||
return File(fileContent, contentType, result.DoculinkAttachments.docName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Handle the exception here or log it
|
||||
return StatusCode(500, "An error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get all Doculink.
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles = "admin")]
|
||||
|
Reference in New Issue
Block a user