File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
samples/client/petstore/csharp/unityWebRequest
net9/Petstore/src/Org.OpenAPITools/Client
standard2.0/Petstore/src/Org.OpenAPITools/Client Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,23 @@ private UnityWebRequest NewRequest<T>(
282282 request = UnityWebRequest . Post ( uri , form ) ;
283283 request . method = method ;
284284 }
285+ else if ( contentType == "application/octet-stream" )
286+ {
287+ if ( options . Data is Stream stream )
288+ {
289+ using ( var binaryReader = new BinaryReader ( stream ) )
290+ {
291+ var bytes = binaryReader . ReadBytes ( ( int ) stream . Length ) ;
292+ request = UnityWebRequest . Put ( uri , bytes ) ;
293+ request . method = method ;
294+ request . SetRequestHeader ( "Content-Type" , "application/octet-stream" ) ;
295+ }
296+ }
297+ else
298+ {
299+ throw new InvalidDataException ( $ "{ nameof ( options . Data ) } is not of { nameof ( Stream ) } type") ;
300+ }
301+ }
285302 else if ( options . Data != null )
286303 {
287304 var serializer = new CustomJsonCodec ( SerializerSettings , configuration ) ;
Original file line number Diff line number Diff line change @@ -282,6 +282,23 @@ private UnityWebRequest NewRequest<T>(
282282 request = UnityWebRequest . Post ( uri , form ) ;
283283 request . method = method ;
284284 }
285+ else if ( contentType == "application/octet-stream" )
286+ {
287+ if ( options . Data is Stream stream )
288+ {
289+ using ( var binaryReader = new BinaryReader ( stream ) )
290+ {
291+ var bytes = binaryReader . ReadBytes ( ( int ) stream . Length ) ;
292+ request = UnityWebRequest . Put ( uri , bytes ) ;
293+ request . method = method ;
294+ request . SetRequestHeader ( "Content-Type" , "application/octet-stream" ) ;
295+ }
296+ }
297+ else
298+ {
299+ throw new InvalidDataException ( $ "{ nameof ( options . Data ) } is not of { nameof ( Stream ) } type") ;
300+ }
301+ }
285302 else if ( options . Data != null )
286303 {
287304 var serializer = new CustomJsonCodec ( SerializerSettings , configuration ) ;
You can’t perform that action at this time.
0 commit comments