Closed Strypper closed 1 year ago
@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
[Multipart]
[Put("/User/TestUpload3")]
Task TestUpload3([AliasAs("Id")] int id, [AliasAs("Name")] string name, [AliasAs("File")] StreamPart file);
I try do this for a cleaner code but the server quickly responded back 400 bad requests
[Multipart]
[Put("/User/TestUpload3")]
Task TestUpload3(TestUploadByteArrayPartDTO1 dto);
public class TestUploadByteArrayPartDTO1
{
[AliasAs("Id")]
public int Id { get; set; }
[AliasAs("Name")]
public string Name { get; set; }
[AliasAs("File")]
public StreamPart File { get; set; }
};
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