I need when client send the id of user , i return file for it as stream. File may be image, PDF, video or sound.
I'm using this code:
[HttpGet]
public async Task<FileStreamResult> GetAvatar(int id)
{
var result = await mediator.Send(new FindUserWithIdCommand { userId = id });
if (result.Success)
{
return uploadService.GetFileStream(result.Result.AvatarName);
}
return null;
}
Upload service:
public FileStreamResult GetFileStream(string FileName)
{
try
{
var stream = File.OpenRead(Path.Combine(finder.PathAvatarUserUploadFolder(), FileName));
FileStreamResult file = new FileStreamResult(stream, "application/octet-stream");
return file;
}
catch (Exception ex)
{
throw;
}
}
but when i send a request for this action in postMan it show me this result:
Where's the problem and how can I solve it?