Using Power Automate To Upload The Attachments From SharePoint Document Library

Please see: Detailed approach on how to bring in an attachment in a SharePoint library (where SP list will have attachments OOTB but not the library). This article is split into three parts for separating the tasks and this is Part 2

Link to Part 1

Create a Power Automate flow, this is required to upload the files to the VendorDocAttachments library

The template for the flow to choose will be Power Apps button


Rename the flow to uploadFiles

Add the following steps to receive the binary data from the PowerApps form, parse JSON value for each file uploaded and store in the SharePoint library. The steps are as follows:

  1. Initialize a string variable to collect the DataStream from the PowerApps form. Rename the variable as varFiles and Ask in PowerApps for values
  2. Initialize second string variable varItemID to collect the Foreign Key (Item ID of Vendor Documents library)
  3. Compose the variable as JSON value by using this

  4. The JSON value to be parsed using Parse JSON using Outputs from compose as content and Schema as the following
        "type": "array",
            "items": {
                "type": "object",
                "properties": {
                "DataStream": {
                "type": "string"
            "Title": {
                "type": "string"
        "required": [

Add an Apply to each control step to Create file uploaded in loop.

Site Address: <site url>

Folder Path: /VendorDocAttachments {where the file needs to be uploaded}

File Name: Title {from the JSON}

File Content: dataUriToBinary(items(‘Apply_to_each’)[‘DataStream’]) {Convert all files to Binary}

Note: DataStream under Parse JSON value will be available for direct addition, but to add inside dataUriToBinary the value may not appear! In the expressions this line of code can be directly added and validate for error. dataUriToBinary(items(‘Apply_to_each’)[‘DataStream’])

Another step is to add Update file properties

Site Address: <site url>

Folder Path: /VendorDocAttachments {where the file needs to be uploaded}

Id: ItemId {Under Create file}

VendorDocumentsID: varItemID {Is the column created in the library an variable from the first second step of the flow}

After the Apply to each control, add an additional step Respond to a Power App which provides a success message to the form. In turn also helps the process flow to be in synchronous order.

Save the flow and go back to the PowerApps form.

In the form, now this flow will be available. Add the flow in the OnSelect property of the button.

Note: Upon adding the flow, the previously added formulas will be erased. Ensure to add them again.

The flow is not set to receive the JSON Binary Data, therefore the datastream from the Gallery control to be converted as JSONFormat which includes the binary data. Followed the Ask in Power Apps value which is the current SharePoint library item ID.


Done! Save the form. All set to upload the files.

To be continued..

Link to Part 3