Class BodyStreamAttribute
Used to indicate that clients generated by Neon.ModelGen should
include a System.IO.Stream stream
parameter holding the data to
be included as the body of the request to the remote service.
note
You may not combine BodyStreamAttribute and FromBodyAttribute attributes on the same model method.
See the remarks for additional details.
Namespace: Neon.ModelGen
Assembly: Neon.Common.dll
Syntax
[AttributeUsage(AttributeTargets.Method)]
public class BodyStreamAttribute : Attribute
Remarks
Model methods tagged with the BodyStreamAttribute will be generated
with System.IO.Stream stream
as the first parameter and the generated client
method will transmit bytes from the current stream position up to the end of the
stream up to the remote service. By default, this will be accomplished using a
8 KiB buffer but this can be customized via BufferSize.
By default the request Content-Type header will be set to application/octet-stream. You can customize this via ContentType.
For input streams that support CanSeek the generated method will also include the Content-Length header. This will be computed by subtracting the current stream position from the stream length.
note
For some situations, you may need to upload from a stream that doesn't support CanSeek
but you already know how many bytes will be transmitted and the server method is expecting a
Content-Length header. In this case, you can wrap your stream with a SubStream
configured with the starting and ending positions of the data in the original stream and then
pass the SubStream as the service client method's stream
argument.
Properties
BufferSize
Optionally specifies the size of the buffer in bytes that will be used by the generated API method for uploading the source stream to the server. This defaults to 8 KiB.
Declaration
public int BufferSize { get; set; }
Property Value
Type | Description |
---|---|
int |
ContentType
Optionally overrides the uploaded content's MIME type. This defaults to application/octet-stream.
Declaration
public string ContentType { get; set; }
Property Value
Type | Description |
---|---|
string |
IncludeContentSize
Indicates that a Content-Size header will be included in the request,
passing the size of the input stream. This defaults to false
.
Declaration
public bool IncludeContentSize { get; set; }
Property Value
Type | Description |
---|---|
bool |