mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-14 16:33:56 +00:00
[REQ] [CSHARP] [UNITYWEBREQUEST] Support Stream for unityWebRequest library (#21704)
* Update ApiClient.mustache * Update ApiClient.mustache
This commit is contained in:
parent
f659457f90
commit
c077d005d5
@ -274,6 +274,23 @@ namespace {{packageName}}.Client
|
|||||||
request = UnityWebRequest.Post(uri, form);
|
request = UnityWebRequest.Post(uri, form);
|
||||||
request.method = method;
|
request.method = method;
|
||||||
}
|
}
|
||||||
|
else if (contentType == "application/octet-stream")
|
||||||
|
{
|
||||||
|
if(options.Data is Stream stream)
|
||||||
|
{
|
||||||
|
using (var binaryReader = new BinaryReader(stream))
|
||||||
|
{
|
||||||
|
var bytes = binaryReader.ReadBytes((int)stream.Length);
|
||||||
|
request = UnityWebRequest.Put(uri, bytes);
|
||||||
|
request.method = method;
|
||||||
|
request.SetRequestHeader("Content-Type", "application/octet-stream");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new InvalidDataException($"{nameof(options.Data)} is not of {nameof(Stream)} type");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (options.Data != null)
|
else if (options.Data != null)
|
||||||
{
|
{
|
||||||
var serializer = new CustomJsonCodec(SerializerSettings, configuration);
|
var serializer = new CustomJsonCodec(SerializerSettings, configuration);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user