gpt4 book ai didi

azure - 在azure逻辑应用程序中如何从json字符串中提取图像并将其保存在sharepoint中

转载 作者:行者123 更新时间:2023-12-03 06:17:07 26 4
gpt4 key购买 nike

在 azure 逻辑应用程序中,我想保存以 json 字符串中的 url 形式给出的图像。它们应该保存在共享点文件夹中。 json 字符串很长,但缩短后看起来有点像这样:

{"id":"123","Person":{"Name":"Testmann","Firstname":"Tim"},"Timestamp":"2023-03-22T20:16:04.663252+01 :00","Tree":{"fileId":"123","fileName":"Tree_2023_03_22_19_16_09.png","timestamp":"2023-03-22T19:16:09.082243Z","contentType":"图片/png","size":123,"url":"https://path"}}

在此示例中,蒂姆·泰斯特曼 (Tim Testmann) 在特定时间拍摄了一棵树的照片。该字符串可以包含多个图像,例如树的根部,不知道会提前出现多少个图像。

有人知道如何将图像保存在sharepoint中吗?人们可能必须首先从字符串中提取所有图像。

非常感谢您的帮助!非常感谢任何帮助。

编辑:

实际的 json 看起来更像下面的版本。有一般信息以及相同 json 类型的多个图像。如何只提取图像并将每张图像保存在共享点中?再次感谢!

{"id":"123","Person":{"Name":"Testmann","Firstname":"Tim"},"Timestamp":"2023-03-22T20:16:04.663252+01 :00","Tree1":{"fileId":"123","fileName":"Tree_2023_03_22_19_16_09.png","时间戳":"2023-03-22T19:16:09.082243Z","contentType":"图片/png","size":63865,"url":"https://path"},"Tree2":{"fileId":"1234","fileName":"Tree2_2023_03_22_19_16_09.png","时间戳": "2023-03-22T19:16:09.082243Z","contentType":"image/png","size":63865,"url":"https://path2","Tree3":{"fileId": “12345”,“文件名”:“Tree3_2023_03_22_19_16_09.png”,“时间戳”:“2023-03-22T19:16:09.082243Z”,“contentType”:“image/png”,“大小”:63865,“url” :“https://path3”}}

最佳答案

从我这边复制后,我可以按照以下步骤实现您的要求。

为了演示目的,我使用了下面的 Json 来获取示例图像 URL。

{
"id": "123",
"Person": {
"Name": "Testmann",
"Firstname": "Tim"
},
"Timestamp": "2023-03-22T20:16:04.663252+01:00",
"Tree": {
"fileId": "123",
"fileName": "Tree_2023_03_22_19_16_09.png",
"timestamp": "2023-03-22T19:16:09.082243Z",
"contentType": "image/png",
"size": 123,
"url": "https://www.thewowstyle.com/wp-content/uploads/2015/02/now-i-am-free.jpg"
}
}

下面是我的逻辑应用程序的完整流程

enter image description here

下面是我的逻辑应用的解析 json 操作架构

{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"Person": {
"type": "object",
"properties": {
"Name": {
"type": "string"
},
"Firstname": {
"type": "string"
}
}
},
"Timestamp": {
"type": "string"
},
"Tree": {
"type": "object",
"properties": {
"fileId": {
"type": "string"
},
"fileName": {
"type": "string"
},
"timestamp": {
"type": "string"
},
"contentType": {
"type": "string"
},
"size": {
"type": "integer"
},
"url": {
"type": "string"
}
}
}
}
}

结果:

enter image description here

enter image description here

更新

<小时/>

这可以使用Json Properties to Name Value Pair Array操作来完成。您可以执行以下操作来实现您的要求。

enter image description here

True block 内的流动

enter image description here

结果:

enter image description here

enter image description here

我的逻辑应用的代码 View

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Compose_2": {
"inputs": "@items('For_each')",
"runAfter": {},
"type": "Compose"
},
"Condition": {
"actions": {
"Create_file": {
"inputs": {
"body": "@body('HTTP')",
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "post",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://<>.sharepoint.com/<>/<>'))}/files",
"queries": {
"folderPath": "/Shared Documents/urlImages",
"name": "@{items('For_each')['propertyValue'][1]['propertyValue']}",
"queryParametersSingleEncoded": true
}
},
"runAfter": {
"HTTP": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"HTTP": {
"inputs": {
"method": "GET",
"uri": "@{items('For_each')['propertyValue'][5]['propertyValue']}"
},
"runAfter": {},
"type": "Http"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@items('For_each')['propertyName']",
"id"
]
}
},
{
"not": {
"equals": [
"@items('For_each')['propertyName']",
"Person"
]
}
},
{
"not": {
"equals": [
"@items('For_each')['propertyName']",
"Timestamp"
]
}
}
]
},
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"type": "If"
}
},
"foreach": "@body('Json_Properties_to_Name_Value_Pair_Array')",
"runAfter": {
"Json_Properties_to_Name_Value_Pair_Array": [
"Succeeded"
]
},
"type": "Foreach"
},
"Json_Properties_to_Name_Value_Pair_Array": {
"inputs": {
"body": {
"data": "@json(triggerBody())"
},
"host": {
"connection": {
"name": "@parameters('$connections')['advanceddataoperatio_1']['connectionId']"
}
},
"method": "post",
"path": "/JsonPropertiesToNameValuePairArray"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"advanceddataoperatio_1": {
"connectionId": "/subscriptions/<subid>/resourceGroups/<rg>/providers/Microsoft.Web/connections/advanceddataoperatio-1",
"connectionName": "advanceddataoperatio-1",
"id": "/subscriptions/<subid>/providers/Microsoft.Web/locations/eastus/managedApis/advanceddataoperatio"
},
"sharepointonline": {
"connectionId": "/subscriptions/<subid>/resourceGroups/<rg>/providers/Microsoft.Web/connections/sharepointonline",
"connectionName": "sharepointonline",
"id": "/subscriptions/<subid>/providers/Microsoft.Web/locations/eastus/managedApis/sharepointonline"
}
}
}
}
}

关于azure - 在azure逻辑应用程序中如何从json字符串中提取图像并将其保存在sharepoint中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76165152/

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