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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to determine the s...
Power Automate
Answered

How to determine the size (Mb) of an attachment in MS Flow

(0) ShareShare
ReportReport
Posted on by 280

Hi all,

 

I just had one of my flows "fail" due to the fact that the attachment to an e-mail exceeded the 5Mb size. I want to build in a check to prevent this from happening. How can I determine the combined size of all attachments of a SharePoint List item?

 

Any feedback is welcome!

 

Regards

Charles

 

Categories:
  • Verified answer
    DeepakS Profile Picture
    2,301 Most Valuable Professional on at

    Hi @Charles-v-D 

     

    Following Expression (approx) will give you the file size:

     KB =  div(int(length(string(body('Get_file_content')))),1024)  (Preferred)

    MB = div(int(length(string(body('Get_file_content')))),1048576)

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • Charles-v-D Profile Picture
    280 on at

    @DeepakS Thanks Deepak! Works like a charm!

     

    regards

    charles

     

     

  • AW0522 Profile Picture
    7 on at

    Hello @Charles-v-D ,

     

    I am also looking into the simplest way to determine the combined size of all attachments of a SharePoint List item. How did you go about accomplishing this?

     

    Regards,

    A. Watts

  • Charles-v-D Profile Picture
    280 on at

    Hi @AW0522 

     

    My flow collects the attachments from the item and then for each of them I increment a variable with the size of each attachment. The size in bytes is determined by:

    div(int(length(string(outputs('Get_attachment_content')?['body']))),1024)
     
    Hope this helps
     

    flow.PNG

  • AW0522 Profile Picture
    7 on at

    Awesome @Charles-v-D!

    Efficient indeed!  Thank you for sharing  👍👍

    Very Best,

    A. Watts

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello Charles,

     

    I applied the solution provided by you and the file size is never truly accurate. I tried putting 1000 instead of 1024 and it got closer. But its always by +- 100 KB to the actual file size.

     

    Any idea why that could be? 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 426

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard