cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Charles-v-D
Helper V
Helper V

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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
DeepakS
Super User
Super User

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.

View solution in original post

5 REPLIES 5
DeepakS
Super User
Super User

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.

View solution in original post

@DeepakS Thanks Deepak! Works like a charm!

 

regards

charles

 

 

AW0522
Frequent Visitor

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

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

Awesome @Charles-v-D!

Efficient indeed!  Thank you for sharing  👍👍

Very Best,

A. Watts

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,606)