【发布时间】:2021-08-18 19:06:48
【问题描述】:
希望我描述的正确,而且可能非常简单
尝试将图像作为 base64 字符串在 json 有效负载中传递给用 Powershell 编写的 azure 函数,同时旨在将其最终作为结构化 azure blob 存储中的图像。
将本地文件编码为Base64:
$content = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.IO.File]::ReadAllText("$fileName")))
打包、发送和接收 json 负载没有问题。
在 Azure 函数中,http 触发器
解码base64
$image = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64Content))
从那里,输出到 blob:
Push-OutputBinding -Name outputBlob -Value $ImageBytes
输出的标准绑定:
{
"name": "outputBlob",
"path": "container/{filename}",
"connection": "connectionName",
"direction": "out",
"type": "blob"
}
生成的 blob 不是图像,假设它是解码。
提前谢谢..
【问题讨论】:
-
您遇到了什么问题?请编辑您的问题并提供该信息。还有
$ImageBytes从哪里来?是不是错字,应该是$bytes? -
能否详细描述您的问题?
标签: azure powershell base64 blob