HTTP API Toolkit HTTP API Toolkit
HTTP API Toolkit HTTP API Toolkit
DocFX + Singulink = ♥

Search Results for

    Method UploadStreamingAsync

    UploadStreamingAsync<TItem>(InterpolatedApiPathHandler, UploadSource, ReadOnlySpan<(string Name, object? Value)>, object?, UploadOptions?, CancellationToken)

    Uploads a file in chunks to an upload endpoint of the service and returns the items that the endpoint's handler streams.

    Declaration
    protected IAsyncEnumerable<TItem> UploadStreamingAsync<TItem>(InterpolatedApiPathHandler path, UploadSource source, ReadOnlySpan<(string Name, object? Value)> query = default, object? command = null, UploadOptions? options = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    InterpolatedApiPathHandler path

    The path of the upload endpoint, relative to the base address. It cannot have a query string.

    UploadSource source

    The file to upload.

    ReadOnlySpan<(string Name, object Value)> query

    The query string parameters of the requests that create and complete the upload, which the endpoint's validator and handler bind. Parameters with a null value are left out.

    object command

    The app's command, which the request that creates the upload sends to the endpoint, serialized as JSON with SerializerOptions. Default is null, which sends none.

    UploadOptions options

    The options of the upload. Default is null, which uses the defaults of UploadOptions.

    CancellationToken cancellationToken

    A token to cancel the upload, which aborts it on the service.

    Returns
    Type Description
    IAsyncEnumerable<TItem>
    Type Parameters
    Name Description
    TItem

    The type of the handler's items.

    Remarks

    The upload runs as UploadAsync<TResult>(InterpolatedApiPathHandler, UploadSource, ReadOnlySpan<(string Name, object? Value)>, object?, UploadOptions?, CancellationToken) describes. It starts when the enumeration starts, and again for each enumeration, and a path that is not valid throws when the method is called. Null items are yielded as null, whether or not the item type is nullable.

    When the completion is made again, its items start with the latest item that the handler produced, which can be the last item already yielded. Ending the enumeration early stops reading the items without aborting the upload, and the handler runs on.

    Exceptions
    Type Condition
    FormatException

    A response of the service is not valid for the protocol, or contained an unrecognized record.

    JsonException

    A response of the service is not valid JSON for its type, such as an item with a missing value where the type does not allow one.

    ArgumentException

    path has a query string or a fragment, is not valid or leads outside the base address.

    IOException

    The source failed to read, such as for a file that changed, or ended before its length.

    OperationCanceledException

    cancellationToken was cancelled, also when the upload failed for another reason at the same time, whose exception is then the inner exception.

    HttpRequestException

    An error occurred while sending the request or reading the response.

    BadRequestApiException

    A 400 (Bad Request) response was returned.

    UnauthorizedApiException

    A 401 (Unauthorized) response was returned.

    ForbiddenApiException

    A 403 (Forbidden) response was returned.

    NotFoundApiException

    A 404 (Not Found) response was returned.

    ConflictApiException

    A 409 (Conflict) response was returned.

    UserChangedApiException

    A 412 (Precondition Failed) response was returned.

    ContentTooLargeApiException

    A 413 (Content Too Large) response was returned.

    UnsupportedMediaTypeApiException

    A 415 (Unsupported Media Type) response was returned.

    ValidationApiException

    A 422 (Unprocessable Content) response was returned.

    UserRequiredApiException

    A 428 (Precondition Required) response was returned.

    TooManyRequestsApiException

    A 429 (Too Many Requests) response was returned.

    ServerErrorApiException

    A 500 (Internal Server Error) response was returned.

    ServiceUnavailableApiException

    A 503 (Service Unavailable) response was returned.

    ApiException

    Any other error response or a 3xx response was returned. Redirects are not followed, except on browser platforms (see Location).

    TaskCanceledException

    The request did not complete within its timeout (see RequestTimeout and SetRequestTimeout(HttpRequestMessage, TimeSpan)). The inner exception is a TimeoutException.

    InvalidOperationException

    RequestTimeout is zero, or negative other than InfiniteTimeSpan.

    © Singulink. All rights reserved.