Ever wished you could create a Power Apps file upload solution to send files directly to a SharePoint document library? This comprehensive guide will show you exactly how to do that, plus how to add metadata to your files automatically. This method is fast, efficient, and gives you all the benefits of SharePoint document libraries. I learned this from my friend and fellow MVP, Luise Freese, and I was inspired by this post that she wrote, and now here’s my post and associated demo video at the bottom.
Why Choose Document Libraries Over List Attachments?
Before we dive into the technical details, let’s understand why you’d want to use a SharePoint document library instead of simple list item attachments:
Document Library Benefits:
- Version History: Track who changed what and when
- Collaboration: Multiple people can work on files simultaneously
- Metadata Organization: Sort and filter files by custom columns
- Folder Structures: Organize files hierarchically
- Sync Capabilities: Connect to OneDrive for offline access
- Advanced Features: Retention policies, legal holds, and compliance
- Better File Management: Easier to bulk download, zip, and send externally
- Searchability: Files are indexed for Microsoft 365 search
- Large File Support: No flow file size limitations
Prerequisites and Setup
This Power Apps file upload solution requires a few key components:
- Power Apps Canvas App (connected to a SharePoint list for metadata)
- SharePoint Document Library (where files will be uploaded)
- Office 365 Groups Connector (for the upload functionality in the app)
Getting Your Site ID and Drive ID
Every SharePoint site and document library has unique identifiers that we’ll need for this solution.
Finding Your Site ID
- Navigate to your SharePoint site
- Copy the URL (e.g.,
https://yourtenant.sharepoint.com/sites/yoursite) - Add
/_api/site/idto the end - Visit the complete URL:
https://yourtenant.sharepoint.com/sites/yoursite/_api/site/id - Copy the GUID that appears – this is your Site ID, highlighted in blue here:
Getting Your Drive ID
The Drive ID is trickier to obtain, but here’s a reliable method:
- Add your document library as a data source in Power Apps
- Upload at least one file to the library (so there’s data to collect)
- Add a temporary button to your app with this code:
ClearCollect(TempCollection, YourLibraryName) - Add a gallery and set its Items property to
TempCollection - Add a text label in the gallery with:
ThisItem.DriveId - Preview the app, click the button, and copy the Drive ID from the gallery, to your clipboard.
Here is something that I demonstrated in the video. This temporary screen with a button and a gallery, showing that I collected from my document library called “Contracts93” and this shows the first item in the gallery. With the drive ID, all of the files in the library will have the same one.
Step 1: Prepare Your Power App Form
Start with a standard SharePoint list form in your Power App. Even if you don’t plan to save data to a list, you need this form to “steal” the attachment control.
Extract the Attachment Control
- Add a SharePoint list form to your screen
- Ensure the list has an attachments field on the form
- Copy the attachment control from the form
- Paste it elsewhere on your screen (now it’s independent)
- Delete the original attachments card from the form
- Rename the copied control to Attachments
Fix the Extracted Control
The attachment control will have some errors after extraction. Fix these:
- Delete the Items property (clear it out)
- Set DisplayMode to:
yourformName.DisplayModeor just DisplayMode.Edit - Remove any error-causing properties like ToolTip
Step 2: Set Up Your Variables
For your Power Apps file upload to work, set these variables in your screen’s OnVisible property (or app’s OnStart):
Set(varSiteId, "your-site-guid-here");
Set(varDriveId, "your-drive-guid-here");
Set(varFolder, ___) - Folder naming options are shown in steps 5 & 6
Replace the GUIDs with your actual Site ID and Drive ID. The varFolder can reference any text input on your form or a variable – this will be the folder name created in SharePoint.
Step 3: Add the Office 365 Groups Connector
- In Power Apps, go to Data > Add data
- Search for Office 365 Groups
- Add the connector to your app
This connector provides the HTTP request functionality we need for the upload.
Step 4: Create the Basic Power Apps File Upload Function
Add a button with this code in the OnSelect property (based on Louise Freese’s original solution):
ForAll(
Attachments.Attachments,
Office365Groups.HttpRequest(
"https://graph.microsoft.com/v1.0/sites/" & varSiteId & "/drives/" & varDriveId & "/root:/" & varFolder & "/" & ThisRecord.Name & ":/content",
"PUT",
ThisRecord.Value
)
);
Reset(Attachments);
This code:
- Loops through each attached file
- Uses the Microsoft Graph API to upload to SharePoint
- Creates folders automatically if they don’t exist
- Resets the attachment control when done
Test this code using just that attachment control and a button with this code in the OnSelect property. Make sure that it works properly before moving to the more complex next step.
Step 5: Integrate Power Apps File Upload with Form Submission
For a complete solution, put the upload code in your form’s OnSuccess property instead of a separate button:
// Store the submitted record
Set(varRecord, frmContract.LastSubmit);
// Set folder name from the submitted data
Set(varFolder, varRecord.Title);
// Upload all attachments
ForAll(
Attachments.Attachments,
Office365Groups.HttpRequest(
"https://graph.microsoft.com/v1.0/sites/" & varSiteId & "/drives/" & varDriveId & "/root:/" & varFolder & "/" & ThisRecord.Name & ":/content",
"PUT",
ThisRecord.Value
)
);
// Reset and navigate to your app's home screen
Reset(Attachments);
Navigate(WelcomeScreen)
Step 6: Adding Metadata to Uploaded Files
This is where it gets sophisticated. Add metadata columns to your uploaded files. Basically you collect just the files uploaded in the last few minutes, since that filter is delegable, and then you filter that small subset of files by a couple of fields that are not delegable, like the Title (or one of the fields you’ll be updating) and the Created By email address.
Add Columns to Your Library
- Go to your SharePoint document library
- Add custom columns (e.g., “Vendor Name”, “Original ID”)
- Refresh your Power App data sources
Enhanced OnSuccess Code
// Store submitted record
Set(varRecord, frmContract.LastSubmit);
Set(varFolder, varRecord.Title);
// Upload files
ForAll(
attachments.Attachments,
Office365Groups.HttpRequest(
"https://graph.microsoft.com/v1.0/sites/" & varSiteId & "/drives/" & varDriveId & "/root:/" & varFolder & "/" & ThisRecord.Name & ":/content",
"PUT",
ThisRecord.Value
)
);
// Get recently uploaded files (within 10 minutes)
Set(
varNowMinus10,
DateAdd(
Now(),
-10,
TimeUnit.Minutes
)
);
// Collect recent uploads
ClearCollect(
colFindUploadedFiles,
Filter(
YourLibraryName,
Created > varNowMinus10
)
);
// Add metadata to uploaded files
ForAll(
Filter(
colFindUploadedFiles,
IsBlank(Title) && 'Created By'.Email = User().Email
) As Data1,
Patch(
YourLibraryName,
LookUp(YourLibraryName, ID = Data1.ID),
{
'Vendor Name': varRecord.'Vendor Name',
'Original ID': varRecord.ID
}
)
);
// Cleanup and navigate back home
Refresh(YourLibraryName);
Reset(Attachments);
Navigate(WelcomeScreen)
Step 7: Display Related Files
This isn’t required, but you may want to create a gallery to show files related to the current record:
// Gallery Items property
Filter(
YourLibraryName,
'Original ID' = varRecord.ID &&
Not(IsFolder)
)
Note: You’ll notice here that the !IsFolder or Not(IsFolder) is not delegable. For a workaround, you could create an extra column in your library that you do not populate with metadata for folders. Take a look at the “Conditional Metadata” section below. For this extra column you could say something like this, which would give you a different column to filter by when displaying the gallery of everything except for folders.
If(!IsFolder,".... your data here")
Gallery Enhancements
- Show file thumbnails: Set an Image control to
ThisItem.Thumbnail.Small - Display file names: Add a label with
ThisItem.'File name with extension' - Enable file opening: Set gallery OnSelect to
Launch(ThisItem.'Link to item') - Hide when creating new items: Set Visible to
frmContract.Mode <> FormMode.New
Power Apps File Upload Troubleshooting Tips
If you come across any problems, here are some ideas and suggestions for working through them.
Power Apps File Upload Common Issues
Files upload but no metadata appears:
- Ensure your library columns exist and are spelled correctly
- Check that the time filter captures your uploads (adjust the 10-minute window if needed)
- Verify the Created By email comparison works in your environment
Tip: My best practice for User().Email since I use it so often, is to set it in a named formula when the app launches. Here is a video I created about named formulas in Power Apps.
Delegation warnings:
- The solution uses ClearCollect to avoid delegation issues
- Keep the time filter reasonable (10 minutes works well)
Attachment control errors:
- Make sure it’s properly extracted from a SharePoint form
- Verify it’s renamed to exactly Attachments
- Check that DisplayMode is set correctly
Variables not working:
- Confirm Site ID and Drive ID are correct GUIDs
- Ensure variables are set before the upload code runs
- Test with simple folder names first
Advanced Features
Power Apps File Upload: Multiple File Types
The solution works with any file type that SharePoint supports. Large files upload directly without flow limitations.
Folder Structures
You can create nested folders by including forward slashes in your varFolder variable:
Set(varFolder, "Contracts/2024/" & txtContractName.Text)
Conditional Metadata
Apply different metadata based on form values, when patching:
{
'Vendor Name': If(chkRushOrder.Value, "RUSH - " & varRecord.'Vendor Name', varRecord.'Vendor Name'),
'Original ID': varRecord.ID,
'Priority': If(chkRushOrder.Value, "High", "Normal")
}
Security Considerations
Users need Contribute permissions on the target document library since files are uploaded directly. This is more secure than many flow-based solutions since there’s no intermediate storage.
Power Apps File Upload Performance Benefits
This direct upload method is significantly faster than flow-based alternatives:
- No flow execution delays
- No file size limitations from flows
- Real-time upload feedback
- Immediate availability of files
When to Use This Solution
This approach is ideal for:
- Contract management systems
- Case management applications
- Document submission portals
- Project file organization
- Any scenario requiring rich file metadata
Consider alternatives if:
- You need complex file processing during upload
- Your organization restricts direct SharePoint API access
- You require extensive approval workflows before file storage
Wrapping Up
This Power Apps file upload method combines the best of both worlds: the simplicity of Power Apps forms with the robust file management capabilities of SharePoint document libraries. By uploading directly to SharePoint, you get faster performance, better organization, and access to all of SharePoint’s advanced document features.
The key insight from Louise Freese’s original blog post was using the Office 365 Groups connector to access Microsoft Graph APIs directly from Power Apps. The metadata enhancement adds significant value by automatically organizing and categorizing your uploaded files.
Remember to test thoroughly in your environment, as SharePoint configurations can vary. Start with the basic upload functionality and gradually add metadata features once you’re comfortable with the core concept.
Learn advanced Power Apps from me, in my course that you can take online any time:
This upload approach will save you time, improve user experience, and give you professional-grade document management capabilities right within your Power Apps solutions.

