I have an Azure HttpTrigger function that use and IBinder to write data to a blob. It works fine for text data that's posted to my function but binary data not valid when written to the blob. I have code similar to what I've seen in other posts and blogs writing, e.g.
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "FileDelivery")] HttpRequest httpRequest,
IBinder myBinder,
ILogger log)
...
using (var writer = myBinder.Bind<TextWriter>(new BlobAttribute(
$"my-files/{filename}", FileAccess.Write)))
{
await writer.WriteAsync(await new StreamReader(httpRequest.Body).ReadToEndAsync());
};
I think the problem is in the TextWriter being used to bind to the blob. I tried to use a BinaryWriter but got the error Can't bind Blob to type 'System.IO.BinaryWriter. No post I've found has described saving binary data to a blob in this way. Is there a blob attribute I'm missing or some other setting that will get this to work?