{"id":110958,"date":"2018-04-27T09:48:57","date_gmt":"2018-04-27T16:48:57","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/"},"modified":"2018-04-27T09:48:57","modified_gmt":"2018-04-27T16:48:57","slug":"howto-upload-return-file","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/","title":{"rendered":"Walkthrough: Use Flow in PowerApps to upload files or return data tables"},"content":{"rendered":"

Since the release of the new Respond to PowerApps functionality this month, we’ve seen people ask about a few different scenarios. In this post we\u2019ll walk through two examples:<\/p>\n

    \n
  1. Upload, and then display in the PowerApp, images stored in OneDrive for Business (or other cloud locations)<\/li>\n
  2. Return a Table of data back to a PowerApp (such as from a SQL query or Excel workbook)<\/li>\n<\/ol>\n

    Uploading and Returning files<\/h2>\n

    The first step is to use the PowerApps trigger. For the first action, choose\u00a0Create File<\/strong>\u00a0from OneDrive for Business<\/strong>.\u00a0On the Create File action, in the File name, select Ask in PowerApps from the Add dynamic content menu. Then, in the File Content, do the same. Your action should look like this:<\/p>\n

    \"\"<\/p>\n

    However, there is a problem with this approach. When PowerApps takes an image in encodes it in a dataURI<\/em>. However, the Create File expects its File Content parameter to be binary<\/em>. Thus, you will need to use an expression to convert from dataURI to binary. It should be: dataUriToBinary(triggerBody()[‘Createfile_FileContent’]).<\/p>\n

    \"\"<\/p>\n

    Next, you will add an action to get the direct link of the file. Add the\u00a0Create share link<\/strong> action and pass in the\u00a0ID<\/strong>\u00a0from the\u00a0Create file<\/strong>\u00a0action. You will want to choose Link type of Direct and Link scope of Anonymous. Finally, you will add the Respond to PowerApps action. Add an output for File URL, and pass the Web URL into that output from the previous action. Now save the flow.<\/p>\n

    \"\"<\/p>\n

    Next, go to your PowerApp and add go to your Camera control that will be taking the image. Go to the OnSelect of the Camera control and select the\u00a0Flow<\/strong>\u00a0button from the\u00a0Action<\/strong>\u00a0tab in the ribbon and add the flow you just created.\u00a0<\/p>\n

    \"\"<\/p>\n

    You will modify this formula slightly in order to set the file URL to a variable that you can use on a different control: Set(FileURL,UploadfileandgetURL.Run(“test.jpeg”,Camera1.Photo).fileurl)<\/p>\n

    Finally, just use the variable you created (in the above example, it’s FileURL) on the Image control, and it’ll render the image inline.\u00a0Note: when this Flow runs from the PowerApp, it will use the connection of the user who is signed into PowerApps, so you should only be creating files in a folder that all app users have access to.<\/em> With these few steps, you were able to build a PowerApp that uploads a file to OneDrive and then displays that file!<\/p>\n

    Returning tables of Data<\/h2>\n

    Another scenario that is now possible is to use a flow to get a table of data — either from SQL, Excel, or another data source. The simple\u00a0Respond to PowerApps<\/strong>\u00a0action only allows you to return back basic strings of data. However, for more advanced users, we do have a way to return a full Table of data by building a JSON schema.<\/p>\n

    Once you have the PowerApps trigger and your action that returns a table (in this example,\u00a0List rows present in a table<\/strong>), you will add the\u00a0Request – Response\u00a0<\/strong>action to the end of your flow. You can leave the Status Code and Headers options as-is, and then in the\u00a0Body<\/strong> you’ll want to pass the whole table of data (not just a particular field). To do this, in the Add dynamic content select\u00a0Show more<\/strong>\u00a0and you should see the outputs from that action – you’ll want to include the List.\u00a0<\/p>\n

    \"\"<\/p>\n

    Now you should save your flow. However, unlike when you use the Respond to PowerApps you’re not done yet — you will also have to get the JSON Schema<\/em> for your response to send to the PowerApp. The easiest way to do this is to:<\/p>\n

      \n
    1. Select Test<\/strong> in the command bar and choose I’ll perform the trigger action<\/strong><\/li>\n
    2. Run the flow, you should see it complete successfully and the status of each action<\/li>\n
    3. In the action (in this case, List rows…) go to the Outputs and copy the value of the list (which starts with [ and ends with ])
      \n\"\"<\/li>\n
    4. Select\u00a0Edit<\/strong>\u00a0flow again<\/li>\n
    5. On the\u00a0Response<\/strong> action, select Use sample payload to generate schema<\/strong><\/li>\n
    6. Paste the content from step 3 in and generate the schema
      \n\"\"\u00a0<\/li>\n<\/ol>\n

      You should now see the schema of your table in the Response<\/strong> action. Save your flow again.<\/p>\n

      Now you’re ready to add your flow to your PowerApp, and use it like you would use any other Table of data in your PowerApp.<\/p>\n","protected":false},"excerpt":{"rendered":"

      This month we released new “Respond to PowerApps” functionality. In this post, we\u2019ll walk through examples of two scenarios: uploading, and then displaying in the PowerApp, images stored in OneDrive for Business (or other cloud locations), and, returning a Table of data back to a PowerApp (such as from a SQL query or Excel workbook).<\/p>\n","protected":false},"author":347,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","power-automate-category":[2836],"power-automate-tag":[],"coauthors":[2913],"class_list":["post-110958","power-automate","type-power-automate","status-publish","hentry","power-automate-category-walkthroughs"],"yoast_head":"\nWalkthrough: Use Flow in PowerApps to upload files or return data tables - Microsoft Power Platform Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Walkthrough: Use Flow in PowerApps to upload files or return data tables - Microsoft Power Platform Blog\" \/>\n<meta property=\"og:description\" content=\"This month we released new "Respond to PowerApps" functionality. In this post, we\u2019ll walk through examples of two scenarios: uploading, and then displaying in the PowerApp, images stored in OneDrive for Business (or other cloud locations), and, returning a Table of data back to a PowerApp (such as from a SQL query or Excel workbook).\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Power Platform Blog\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 min read\" \/>\n\t<meta name=\"twitter:label2\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data2\" content=\"Stephen Siciliano\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/\",\"name\":\"Walkthrough: Use Flow in PowerApps to upload files or return data tables - Microsoft Power Platform Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.png\",\"datePublished\":\"2018-04-27T16:48:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#primaryimage\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.webp\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.webp\",\"width\":1292,\"height\":421,\"caption\":\"graphical user interface, application\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Power Automate\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Walkthrough: Use Flow in PowerApps to upload files or return data tables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\",\"name\":\"Microsoft Power Platform Blog\",\"description\":\"Innovate with Business Apps\",\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization\",\"name\":\"Microsoft Power Platform Blog\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png\",\"width\":194,\"height\":145,\"caption\":\"Microsoft Power Platform Blog\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Walkthrough: Use Flow in PowerApps to upload files or return data tables - Microsoft Power Platform Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/","og_locale":"en_US","og_type":"article","og_title":"Walkthrough: Use Flow in PowerApps to upload files or return data tables - Microsoft Power Platform Blog","og_description":"This month we released new \"Respond to PowerApps\" functionality. In this post, we\u2019ll walk through examples of two scenarios: uploading, and then displaying in the PowerApp, images stored in OneDrive for Business (or other cloud locations), and, returning a Table of data back to a PowerApp (such as from a SQL query or Excel workbook).","og_url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/","og_site_name":"Microsoft Power Platform Blog","og_image":[{"url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 min read","Written by":"Stephen Siciliano"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/","name":"Walkthrough: Use Flow in PowerApps to upload files or return data tables - Microsoft Power Platform Blog","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#primaryimage"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.png","datePublished":"2018-04-27T16:48:57+00:00","breadcrumb":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#primaryimage","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.webp","contentUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/upload-return-file-create-file.webp","width":1292,"height":421,"caption":"graphical user interface, application"},{"@type":"BreadcrumbList","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/"},{"@type":"ListItem","position":2,"name":"Power Automate","item":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/"},{"@type":"ListItem","position":3,"name":"Walkthrough: Use Flow in PowerApps to upload files or return data tables"}]},{"@type":"WebSite","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/","name":"Microsoft Power Platform Blog","description":"Innovate with Business Apps","publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization","name":"Microsoft Power Platform Blog","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png","contentUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png","width":194,"height":145,"caption":"Microsoft Power Platform Blog"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/"}}]}},"msxcm_display_generated_audio":false,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Power Platform Blog","distributor_original_site_url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate\/110958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/types\/power-automate"}],"author":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/users\/347"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/comments?post=110958"}],"version-history":[{"count":0,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate\/110958\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/media?parent=110958"}],"wp:term":[{"taxonomy":"power-automate-category","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate-category?post=110958"},{"taxonomy":"power-automate-tag","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate-tag?post=110958"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/coauthors?post=110958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}