4

In my Web API, I need to receive files and then save them in Blob Sorage. Clients are not allowed to access and are not aware of the Blob Storage.

I'm trying to avoid buffering files, which could be up to 300 MB in size. I've seen this post...

How do I pass a Stream from a Web API to Azure Blob Storage without temp files?

... but the solution described in the post is not going to work for me because it assumes multipart content which in turn allows for custom providers.

Clients that I need to deal with are not sending files using multipart content. Instead, they simply send file content in message bodies.

Here is what works for me now (with buffering):

using (var inStream = await this.Request.Content.ReadAsStreamAsync())
{
    var blob = container.GetBlockBlobReference(fileName);
    var outStream = await blob.OpenWriteAsync();
    await inStream.CopyToAsync(outStream);
    outStream.Close();
}

Is there a way to connect a Request's Stream with a Blob Stream without the former being buffered?

bubbleking
  • 3,329
  • 3
  • 29
  • 49
bdristan
  • 1,048
  • 1
  • 12
  • 36

0 Answers0