Closed guillaume-chervet closed 7 months ago
Hi,
I would like to know what is the best way to serialize an object to string.
Officially, we do not provide any views as string format.
Therefore, please consider the common method of encoding binaries into strings.
For example, the standard lib has Convert.ToBase64String
.
Other question, do you have a sample how to make an HTTP client POST a bytes array
Seems like a basic topic that is off topic for this repo. Also, I think it depends on the framework you are using, so I will just suggest the following here.
application/octet-stream
. If you want to send binary data via API, octet-stream may be suitable.You can probably find samples by looking up these keywords.
EDIT:
I brought up application/octet-stream
in general terms, but let me correct myself.
The README defined a Content-Type of application/x-memorypack
.
The following sections of the README may be helpful.
If you call from HttpClient, you can set application/x-memorypack to content-header. var content = new ByteArrayContent(bin) content.Headers.ContentType = new MediaTypeHeaderValue("application/x-memorypack");
Sorry, I forgot to mention. Officially, we provide MemoryPack.AspNetCoreMvcFormatter
package, which may be helpful if you are using ASP .NET Core. thanks.
Hi Thank you for your awseome library.
I am not good at writing optimized code in C#. I would like to know what is the best way to serialize an object to string.
I do not manage to make it works.
Other question, do you have a sample how to make an HTTP client POST a bytes array (for example a multipart form data) to an C# API and how to read it back and convert it back to the original data inside ASP.NET Core ?