web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Restricting or blockin...
Power Automate
Unanswered

Restricting or blocking file extension in SharePoint

(0) ShareShare
ReportReport
Posted on by 2

How do I restrict video files (mp4, wmv, etc. extensions) by file extensions in Sharepoint Online.  My trigger was When a "File is Created" then the output would be to just delete the file that was just uploaded.  Is that possible?  PLease advise.  Thanks.

Categories:
I have the same question (0)
  • CFernandes Profile Picture
    8,402 Most Valuable Professional on at

    @RayJ30 

     

    You can use the  'When a file is created(properties only)' trigger instead of 'When File is created'

     

    You can extract the extension, See steps below in article https://clavinfernandes.wordpress.com/2019/11/12/create-a-flow-using-the-soap-connector/ (I explain but you get extract extension).

     

    CFernandes_0-1598603911768.png

    The use a 'Condition' or 'Switch Case' and delete the file.

     

    I hope it helps.

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

     

  • JisungHan Profile Picture
    on at

    Thanks @CFernandes for your sharing!

  • RayJ30 Profile Picture
    2 on at

    Hi @CFernandes , 

     

    Thanks for the recommendation.  Is there any way to do it without having to use the SOAP connector and adding a server?  We're trying to get rid of our On-prem servers as it's going to be hosted on an external data centre.  I was just tasked to move the videos to Stream and block videos in SharePoint Online, it's actually the first Flow I'm trying to create.  Thank you.

  • CFernandes Profile Picture
    8,402 Most Valuable Professional on at

    Hey @RayJ30 

     

    You do not need to worry about the SOAP connector(Ignore it).

     

    Follow the Steps 3a to 3e in the article.

     

    Step 3a: The SharePoint “When a file is created or modified (properties only)” does not provide us the File extension for the file.  To get the file extension we need to perform the steps shown below.

     

     

    Step 3b: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get File Name”.

    • Name: Set it to “Filename“.
    • Type: Set it to  “String”.
    • Value: Add “File name with extension” the output from the “When a file is created or modified (properties only)” action.
     

     

    Note: If you are new to Power Automate (Microsoft Flow), please refer to the article on how to use expressions in flow actions.

     

    Step 3c: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get File Name Length” .

    • Name: Set it to “Filelength“.
    • Type: Set it to “Integer” .
    • Value: Set it to Expression “length(variables(‘Filename’))“.
     

     

    Step 3d: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get Extension Length”.

    • Name: Set it to “Extensionlength“.
    • Type: Set it to “Integer”.
    • Value: Set it to “Expression” “sub(variables(‘Filelength’),lastIndexOf(variables(‘Filename’),’.’))
     

     

    Step 3e: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get File Extension”.

    • Name: Set it to “Get File Extension“.
    • Type: Set it to “String”.
    • Value: Set it to “Expression” “substring(variables(‘Filename’),lastIndexOf(variables(‘Filename’),’.’),variables(‘Extensionlength’))“.
     

     

    Step 3f: Add the “Compose” action to the Flow Canvas and Rename it to “Replace . From the Get File Extension”.

    • Inputs: Set it to “Expression”
      replace(variables(‘Get File Extension’),’.’,”)“.
     

    At the end of the above step we will  have the “File Extension” and we will can use in you in Power Automate, condition, switch statement.

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard