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

标签 azure sharepoint azure-logic-apps logic-app

在 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/

相关文章:

javascript - Rally App SDK 2.0/SharePoint 集成

azure - 如何在逻辑应用 HTTP 触发器/操作上启用“即发即忘”/异步模式?

azure - 如何为多个 Http 请求(例如 POST、GET 等)创建单个逻辑应用程序

azure - 使用 powershell 如何通过运行 ID 重新运行 Azure 数据工厂中失败的管道?

python-2.7 - 根据类型或类别列出 Microsoft Azure 计算中的 VM 大小

html - 在编辑模式下向内容编辑器 Web 部件添加更宽的图像使其重叠

sharepoint - 从自定义操作启动 SPD 2013 工作流,然后重定向到主页

azure - 如何通过更改模型阈值来操作已发布 Web 服务中的 Azure ML 建议

python - 如何在视频上n秒后运行特定代码

c# - 替换 Azure 逻辑应用中的字符串