Improving File Upload Reliability in SharePoint with Power Automate: A ‘Do Until’ Approach

Sarah Nmachi
4 min readMay 22, 2023

--

I’m working on copying files from a public SharePoint site to a private SharePoint site as soon as they are uploaded, and then deleting them from the original location. After receiving an email notification from my Power Automate flow stating that the file upload has been completed and received, I eagerly check in SharePoint, only to discover that the upload was either canceled or failed.

When it comes to SharePoint, there are various reasons why you might need to move files between Sites. One common scenario is when you have a SharePoint document link that is only available to the public for a limited time, such as 24 hours. To ensure the security of sensitive information being uploaded, moving these files and restricting their availability to the public becomes necessary.

This article delves into an effective approach to enhance file upload reliability in SharePoint by leveraging Power Automate and implementing a ‘Do Until’ loop. It focuses on overcoming the challenge of minimizing failures and ensuring successful file transfers between SharePoint sites, especially when handling large files. By harnessing the power of Power Automate and employing a ‘Do Until’ loop, organizations can significantly improve the overall efficiency and reliability of their SharePoint file upload processes

Fig 1

From the Snip Above in Fig 1, we implemented a simple Power Automate flow that triggers when a file is uploaded to a SharePoint list.

While this flow appears to be straightforward and functional, it has a limitation. When uploading large files to the SharePoint document library, the flow executes successfully, but the file upload fails.

Fig 2
Fig 3

If we look at the time stamp of Fig 2 and Fig 3 , we can see that while Power Automate Flow ran successfully, SharePoint Upload Fails.

This issue arises because Power Automate copies the file properties, leading to the creation, copying, and deletion processes occurring almost instantly before the upload is complete.

Solution:
To overcome this issue, we can incorporate a “do until” condition into the flow. By adding a condition, we can periodically check if the file has finished uploading, allowing us to synchronize the flow accordingly. In this article, we will demonstrate how to implement this solution using a 5-minute interval.

Within the flow, we will focus on monitoring the file metadata as an indicator of completion. The file metadata remains at zero until the upload process is fully completed. The steps involved in the above solution are as follows:

Variable Initialization:
— Initialize a variable named “metadata” to track the file metadata.

Do Until Condition:
— Create a “do until” condition that runs every 5 minutes for a duration of 1 hour.
— To verify whether the file metadata is still zero within the condition, retrieve the size of the file metadata(Get File metadata) and assign it to the `initialized` variable (Set Variable).

Fig 4

Condition Control

Create an If Statement. This runs after the Do Until Condition
— If the DO UNTIL condition times out and the metadata remains zero, you can choose to either take no action (do nothing) or go the extra mile by sending a notification to indicate that the upload was canceled or failed.
— If the metadata is not zero, perform the following tasks: copy the file to the internal site, delete the file from the public site, and finally, send an email to confirm the successful upload.

Fig 5

Conclusion:

Fig 6

By incorporating a “do until” Condition with periodic checks for file metadata, we can ensure that the file upload process in SharePoint using Power Automate is efficient and reliable. Please Note that there may be other ways to approach this issue however this is my current approach to solve this issue.

It is important to note that the duration and frequency of the condition can be adjusted based on specific requirements. For more detailed information on implementing the “do until” condition, refer to the provided Microsoft Documentation.

--

--

No responses yet