You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AllowAnonymous][HttpPost]publicasyncTask<IActionResult>Register([FromForm]UserSignUpDTOdto,CancellationTokencancellationToken=default){varuser=new User(){UserName= dto.username,Email= dto.email
};varresult=await _userRepository.CreateAccount(user, dto.password);if(result.Succeeded){if(dto.avatarfile isnull)return Ok();if(_mediaService.IsImage(dto.avatarfile)){using(Streamstream= dto.avatarfile.OpenReadStream()){Tuple<bool,string>uploadresults=await _mediaService.UploadAvatarToStorage(stream, dto.avatarfile.FileName);varisUploaded= uploadresults.Item1;varstringUrl= uploadresults.Item2;if(isUploaded&&!string.IsNullOrEmpty(stringUrl)){
user.ProfilePic =stringUrl;await _userRepository.UpdateUser(user, cancellationToken);return Ok();}elsereturn BadRequest("Look like the image couldnt upload to the storage, but your account have created successfully");}}}return BadRequest();}
As you can see the avatarfile is an IFormFile which we included inside this object, so far we haven't found a way to use refit to send this kind of object to our backend to recognize.
If we don't have a solution, we must call 2 requests to complete our registration process. we had the code for uploading files in using the System.Net.Http will be this massive like this
This is an example of my previous object uploading a file to ASP.NET
@duydh1995 have done the investigation about this issue and found out some of the ByteArrayPart and the StreamPart type
On the server, asp.net seem to accept the DTO
But on the front end in order to make create such an accepted request that it has to be in a format like below
Description
Please see the refit documents for this issue: https://github.com/reactiveui/refit
Situation
This is refit example showing us how to upload file through HTTP
The problem
Our API in Intranet Authentication Controller
UserSignUpDTO:
As you can see the
avatarfile
is anIFormFile
which we included inside this object, so far we haven't found a way to use refit to send this kind of object to our backend to recognize.If we don't have a solution, we must call 2
requests
to complete our registration process. we had the code for uploading files in using theSystem.Net.Http
will be this massive like thisThis is an example of my previous object uploading a file to ASP.NET
Public API Changes
Intended Use-Case
Create user information with an avatar with only one call
The text was updated successfully, but these errors were encountered: