Fix null reference issue in DocumentController
Added a null-conditional operator (`?.`) to safely access the `ByteData` property of the `senderDoc` object, preventing a potential `NullReferenceException` when `senderDoc` is null.
This commit is contained in:
@@ -37,7 +37,7 @@ public class DocumentController(IMediator mediator, IAuthorizationService authSe
|
|||||||
return BadRequest("Missing document query.");
|
return BadRequest("Missing document query.");
|
||||||
|
|
||||||
var senderDoc = await mediator.Send(query, cancel);
|
var senderDoc = await mediator.Send(query, cancel);
|
||||||
return senderDoc.ByteData is byte[] senderDocByte
|
return senderDoc?.ByteData is byte[] senderDocByte
|
||||||
? File(senderDocByte, "application/octet-stream")
|
? File(senderDocByte, "application/octet-stream")
|
||||||
: NotFound("Document is empty.");
|
: NotFound("Document is empty.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user