LowCodeStacks
Sign in

Save Power Apps attachments and photos to a SharePoint library

Canvas apps can't write files to a SharePoint document library on their own. Here's the pattern that works: a Power Apps (V2) flow with a File input, called from the app with an attachment, a camera photo or a generated PDF. Plus list attachments with no flow, and the Dataverse file-column alternative.

Power AppsFix · Tutorial4 min read

Checked against Microsoft Learn · 5 sourcesHow we write guides

A canvas app can attach files to a SharePoint list item, but it can't put a file into a document library by itself. The reliable way is to hand the file to a small Power Automate flow that runs Create file. Here's how, for the three things people usually want to save: an attachment, a photo and a PDF.

Pick the right destination

You wantUse
Files attached to a list itemThe Attachments control in a form, or the modern Attachments control (section 4). No flow needed
Files in a document library, with their own columns and versionsA flow with a File input (sections 1–3)
Files stored with a Dataverse rowA Dataverse file column, written straight from the app (section 5)

1. Build the flow

  1. In Power Apps Studio, open the Power Automate pane and select Create new flow → Create from blank.
  2. Delete the default PowerApps trigger and add PowerApps (V2) instead.
  3. In the trigger, select Add an input:
    • File, for the file content;
    • Text, renamed to File Name.
  4. Add SharePoint Create file:
    • Site Address and Folder Path: your library;
    • File Name: the File Name input;
    • File Content: the trigger's file content.
  5. Optional: add Update file properties to fill the library's columns, such as the related request ID.
  6. Save, and close the pane. The flow now appears in the app's list.

2. Call it from the app

Flows with a File input take an object with name and contentBytes.

From an attachment (an Attachments control in a form):

powerfx
ForAll(
    DataCardValue_Attachments.Attachments,
    SaveToLibrary.Run(
        ThisRecord.Name,
        { file: { name: ThisRecord.Name, contentBytes: ThisRecord.Value } }
    )
)

From a photo (Camera control):

powerfx
Set(photoName, "Inspection-" & Text(Now(), "yyyymmdd-hhmmss") & ".jpg");
SaveToLibrary.Run(photoName, { file: { name: photoName, contentBytes: Camera1.Photo } })

From a generated PDF (the PDF function is experimental, so turn it on under Settings → Upcoming features):

powerfx
SaveToLibrary.Run(
    "Report.pdf",
    { file: { name: "Report.pdf", contentBytes: PDF(ReportScreen) } }
)

Replace SaveToLibrary with your flow's name, as the app shows it.

Tip

Give every file a unique name, for example with a date and time, a record ID or both. Two users saving photo.jpg would otherwise collide.

3. Tell the user it worked

Make the flow end with Respond to a PowerApp or flow, returning the new file's link. Then in the app:

powerfx
Set(result, SaveToLibrary.Run(photoName, { file: { name: photoName, contentBytes: Camera1.Photo } }));
Notify("Saved: " & result.link, NotificationType.Success)

link is whatever output name you gave in Respond to a PowerApp or flow.

4. List attachments without a flow

If the files only need to live on the list item:

  • In a form: the SharePoint Attachments card saves with SubmitForm. Set MaxAttachments and MaxAttachmentSize (in MB) on the control.
  • Without a form (preview): the modern Attachments control can update a list item's attachments directly with Patch. Set its Items to the selected record's Attachments.

The classic Attachments control's Items must be the record's Attachment column. Collections and tables aren't supported.

5. Dataverse instead of SharePoint

If your app uses Dataverse, add a file column to the table. The modern Attachments control can then save a file straight into that column with Patch, mapping the file's name and content. Saving replaces the file already there. Keep MaxAttachmentSize within the column's maximum.

When it goes wrong

SymptomCheck
The flow isn't in the app's listIt must start with the PowerApps (V2) trigger. Refresh the flows pane
"Missing parameter", or the file is emptyPass { file: { name: …, contentBytes: … } }, not the control itself
Files saved but they won't openCheck the extension in the name matches the content, such as .jpg for camera photos
Works for you, fails for othersThe flow uses their connection, so they need permission to add files to that library. Or set the flow to use your connection under Run only users
Large files failLower MaxAttachmentSize, and test the biggest file you expect

Sources