[英]why is the blob being created as empty?
为什么创建的Blob没有任何内容?
我有一个输出绑定集,用于在下面创建blob:
public static class OnSchedulingToMMMQueueTriggered
{
[FunctionName("OnSchedulingToMMMQueueTriggered")]
public static void Run(
[QueueTrigger("httpqueue", Connection = "OnSchedulingToMMMQueueTriggered:SourceQueueConnection")] MyPayload myQueueItem,
[Blob("processed/{Payload}", FileAccess.Write, Connection = "OnSchedulingToMMMQueueTriggered:ProcessedPayloadsConnectionString")] Stream processedPayload,
ILogger log)
{
log.LogInformation($"C# Queue trigger function processed: {myQueueItem.Payload}");
processedPayload = StreamGenerator.GenerateStreamFromString(myQueueItem.Payload);
}
}
它创建了一个Blob,并为它分配了正确的命名,并带有processed/{Payload}
; 但是,当我检查一下斑点内的内容时,它是空的!
我假设这不起作用:
processedPayload = StreamGenerator.GenerateStreamFromString(myQueueItem.Payload);
我要遵循的示例是此示例,从这里开始 :
[FunctionName("ResizeImage")]
public static void Run(
[BlobTrigger("sample-images/{name}")] Stream image,
[Blob("sample-images-sm/{name}", FileAccess.Write)] Stream imageSmall, //output blob
[Blob("sample-images-md/{name}", FileAccess.Write)] Stream imageMedium)
{
//your code here
}
为什么将Blob创建为空?
这是我的StreamGenerator
实现:
public static class StreamGenerator
{
public static Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
}
似乎您的代码将生成的流分配给本地var processedPayload
你可能想要
StreamGenerator.GenerateStreamFromString(myQueueItem.Payload).CopyTo(processedPayload)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.