ASP.NET Core Web API byte[] issues
Hello there,
I am trying to accept a byte array in my API request:
Swagger is used to test the API. When I launch the project and open it in my browser I see that this property accepts a string instead of a byte[]. Googling this issue did not gave much information besides this SO-thread
https://stackoverflow.com/questions/77233543/call-an-api-with-byte-array-in-net-6
My question is if this is good enough or has anyone else faced similar issues?
Stack Overflow
Call an api with byte array in .NET 6
I am creating an ASP.NET Core 6 Web API. I did enable Swagger and would like to test an endpoint with input body of datatype byte[].
[HttpPost(Name = "publishdata")]
public IActionResult ...
10 Replies
does this mean i need to send base64 strings anyway or?
I wonder if sending images to an API is even good practice at all 😅
its not, and if its done, its usually via a file upload.. or base64
you never really do
[12,8,7,..]
:d
since the byte size of that is significantly larger than a base64 stringSo just uploading a base64 string is the most senseful way to upload an image to the API?
no I didn't say that
I mean there are more ways to get to Rome
I'd use literal file upload, but yeah the second most common is probably base64 string
I will look on literal file upload tomorrow and compare it with the base 64
What I find hard about programming now is that when having my first job is making choices
Since there are so many ways of implementing something and all have their pros and cons
yup.