Skip to content

DownloadAttachment as Stream #152

Closed
Closed
@emrecaglar

Description

@emrecaglar

A stream-returning method is required to access the file from memory without writing it to disk.

DownloadAttachmentAsync like

public async Task<Stream> DownloadAttachmentAsStreamAsync(CouchAttachment attachment, CancellationToken cancellationToken = default)
{
    Check.NotNull(attachment, nameof(attachment));

    if (attachment.Uri == null)
    {
        throw new InvalidOperationException("The attachment is not uploaded yet.");
    }

    return await NewRequest()
        .AppendPathSegment(attachment.DocumentId)
        .AppendPathSegment(Uri.EscapeUriString(attachment.Name))
        .WithHeader("If-Match", attachment.DocumentRev)
        .GetStreamAsync(cancellationToken)
        .ConfigureAwait(false);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions