PowerApps-显示自定义连接器通过ASP.NET API接收的图像

PowerApps-显示自定义连接器通过ASP.NET API接收的图像,asp.net,azure-web-app-service,azure-active-directory,powerapps,Asp.net,Azure Web App Service,Azure Active Directory,Powerapps,我正在使用Azure托管的ASP.NET API将项目从我的后端交付到PowerApps画布应用程序。某些项目具有指定给它们的图像。在这些情况下,我提供图像ID,以便使用GetImage(ID)方法按需下载图像。在这个方法中,我返回HTTPResponse中的内容。到目前为止,这是可行的。我可以从浏览器调用该方法,并显示图像。在移动设备上,我不能直接使用URL,因为连接由Azure AD保护。我需要使用自定义连接器的方法结果接收图像。不幸的是,我找不到一种方法来用包含原始图像数据的字符串填充图像

我正在使用Azure托管的ASP.NET API将项目从我的后端交付到PowerApps画布应用程序。某些项目具有指定给它们的图像。在这些情况下,我提供图像ID,以便使用GetImage(ID)方法按需下载图像。在这个方法中,我返回HTTPResponse中的内容。到目前为止,这是可行的。我可以从浏览器调用该方法,并显示图像。在移动设备上,我不能直接使用URL,因为连接由Azure AD保护。我需要使用自定义连接器的方法结果接收图像。不幸的是,我找不到一种方法来用包含原始图像数据的字符串填充图像控件。怎么能做到呢? 我可以返回API中的任何其他类型,如果这样可以解决问题的话

问候


Sven

您可以直接从自定义连接器将图像返回到应用程序。在定制API的响应中,您需要将格式定义为二进制,将媒体类型定义为图像

        "responses": {
          "default": {
            "description": "default",
            "schema": {
              "type": "string",
              "format": "binary",
              "x-ms-media-kind": "image"
            }
          }
        },
例如,这是一个Azure函数,它在给定代码的情况下返回条形码(不是生产就绪,更多的是概念证明):

然后定义

{
  "swagger": "2.0",
  "info": {
    "title": "BarcodeGenerator",
    "description": "Barcode generator",
    "version": "1.0"
  },
  "host": "YOUR_FUNCTION_APP_NAME_HERE.azurewebsites.net",
  "basePath": "/api/",
  "schemes": [
    "https"
  ],
  "consumes": [],
  "produces": [],
  "paths": {
    "/BarcodeGenerator": {
      "get": {
        "responses": {
          "default": {
            "description": "default",
            "schema": {
              "type": "string",
              "format": "binary",
              "x-ms-media-kind": "image"
            }
          }
        },
        "summary": "Generate barcode",
        "description": "Generate a barcode.",
        "operationId": "GenerateBarcode",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "type": "integer"
          },
          {
            "name": "width",
            "in": "query",
            "required": false,
            "type": "integer"
          },
          {
            "name": "height",
            "in": "query",
            "required": false,
            "type": "integer"
          }
        ]
      }
    }
  },
  "definitions": {},
  "parameters": {},
  "responses": {},
  "securityDefinitions": {},
  "security": [],
  "tags": []
}

希望这有帮助

您是否尝试过使用Azure Blob存储连接器?不幸的是,这没有帮助,因为我的图像是从后端ERP交付的。将它们存储在Azure中不是一个选项。
{
  "frameworks": {
    "net46":{
      "dependencies": {
        "ZXing.Net": "0.16.4"
      }
    }
   }
}
{
  "swagger": "2.0",
  "info": {
    "title": "BarcodeGenerator",
    "description": "Barcode generator",
    "version": "1.0"
  },
  "host": "YOUR_FUNCTION_APP_NAME_HERE.azurewebsites.net",
  "basePath": "/api/",
  "schemes": [
    "https"
  ],
  "consumes": [],
  "produces": [],
  "paths": {
    "/BarcodeGenerator": {
      "get": {
        "responses": {
          "default": {
            "description": "default",
            "schema": {
              "type": "string",
              "format": "binary",
              "x-ms-media-kind": "image"
            }
          }
        },
        "summary": "Generate barcode",
        "description": "Generate a barcode.",
        "operationId": "GenerateBarcode",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "type": "integer"
          },
          {
            "name": "width",
            "in": "query",
            "required": false,
            "type": "integer"
          },
          {
            "name": "height",
            "in": "query",
            "required": false,
            "type": "integer"
          }
        ]
      }
    }
  },
  "definitions": {},
  "parameters": {},
  "responses": {},
  "securityDefinitions": {},
  "security": [],
  "tags": []
}