gpt4 book ai didi

java - java中使用Blob触发器的azure函数的传入内容应声明哪个类

转载 作者:行者123 更新时间:2023-11-30 06:08:30 25 4
gpt4 key购买 nike

我完成了java azure函数教程。并希望使用 Blob 触发器而不是 httptrigger 构建我的 azure 函数。

public class Function {

@FunctionName("myfunction")
@StorageAccount("xxxxxxxxx")
public void blobHandler(
@BlobTrigger(name = "content", path = "container/{name}", dataType = "binary") byte[] content,
@BindingName("name") String name, final ExecutionContext context
) {
context.getLogger().info("Java Blob trigger processed a request.");
try {
context.getLogger().info("Java Blob trigger function processed a blob. Name: " + name + "\n Size: " + content.length + " Bytes");
// process the CT converter function
} catch (Exception e) {
//TODO: handle exception
context.getLogger().info("Error");
}

}
}

然后当我发现我应该使用 Stream 作为数据类型而不是像 C# 中那样使用 Binary (dataType = "Stream") 。但是我无法找到应该使用哪个 java 类作为内容的流数据类型。只是流类?尝试过,但它对我不起作用。有人对此有更多经验吗?

最佳答案

目前不支持

Stream。看这个github issue .

Document

You are free to use all the data types in Java for the input and output data, including native types, customized Java types and specialized Azure types defined in azure-functions-java-core package.

对于blobtrigger,我们可以使用Stringbyte[]、POJO类进行blobtrigger内容绑定(bind)。注意,使用POJO时,必须省略参数dataType

关于java - java中使用Blob触发器的azure函数的传入内容应声明哪个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50758413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com