PowerApps V2 File Upload from Canvas App and Store in Sharepoint

When we want to upload multiple files at one shot, currently there is no direct input control to
upload

So, this is a workaround where we get the File upload control from Edit Form Option

High level resolution steps

    • Add an edit form and copy the file upload option from edit form to outside of edit form and
      delete the edit form.
    • Create a Sharepoint list to store all the attachments in Sharepoint
    • Create a flow to trigger and save the attachments from canvas app to Sharepoint.

    Detailed resolution steps

      Step 1: Add an edit form control to the screen and connect to a Sharepoint list that has attachment field in it.

      Copy the Attachment control out of edit form and delete the edit form.

      Step 2: Create a Power Automate flow, and in the trigger add a file attachment input as shown below:

      Step 3:

      Add a “create file” action and select the site address from the dropdown where your Sharepoint list has been stored, then select the folder path where the files have to be stored.

      In file name field, we have to map the name of the file – but there is no direct dynamic content, so we make a work around by giving the below formula:

      @{triggerBody()[‘file’][‘name’]}

      And for the file content – give the input from trigger

      Step 4:

      Step 5: Add a button and enter the below code in the OnSelect Property of the button as below:

      ForAll(DataCardValue14_1.Attachments As
      FILE,FileUploader.Run({file:{contentBytes:FILE.Value,name:FILE.Name}}));
      Reset(DataCardValue14_1);Notify(“All Files have been uploaded”)

      Code Explaination:

      ForAll – means select all the records/Attachments in the control.

      As FILE – means the attachments will be uploaded as a file.

      FileUploader.Run – is the name of the flow and has to run the flow.

      File:{contentBytes:FILE.Value – to get the file value of what it contains

      FILE:name – the name of the file

      Reset – To reset the file upload control to 0

      Notify – to receive a notification in the canvas app saying that files have been uploaded.

      Output

      I have uploaded a file called “Sample Receipt” in canvas app and on click of a button the file gets
      uploaded via Power Automate and stores in Sharepoint.

      Uploaded the file here in Canvas app

      Then the Flow Will run

      And it has been stored in Sharepoint as shown below: