cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Responsive Resident
Responsive Resident

Attachment control file size minimum validation

I want to prevent users from being able to upload files if they are 0KB. I know there is a MaxAttachmentSize property on the attachments control but not seeing anything for minimum.

When accessing the most recently added attachment in the control, it seems I can only access the Value and Name properties of the attachment, not seeing anything for size. Example:

Last(AttachmentsControl.Attachments).Name

Is there any way to access the size of each attachment? 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Cooper01 ,

 

It seems that it can only upload the file to the attachment column first, then automatically obtain the size of the file, and finally decide whether to keep the file or delete the file based on the size.

Because in your app, users upload local files.

 

If you have many files in the sharepoint library(in cloud), you could decide whether to move them to the attachment column according to their size. This can avoid completing the upload action.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

5 REPLIES 5
v-xiaochen-msft
Community Support
Community Support

Hi @Cooper01 ,

 

If you want to detect the size of the attachment first, then decide whether to upload the attachment based on the size, it may be difficult to achieve.

I suggest you change the way to achieve a similar effect.

 

Firstly, the user uploads the attachments.

Secondly, the operation triggers the flow, which detects the size of the attachments.

Finally, if the size of the attachment is 0KB, delete it.

 

I did a test for you:

1\ Build an instant flow

v-xiaochen-msft_0-1611646559068.png

 

 

Get attachments Id: Ask in Powerapps

 

 

v-xiaochen-msft_1-1611646559072.png

 

 

Get attachment content Id : Ask in powerapps
Compose Inputs: div(int(length(string(outputs('Get_attachment_content')?['body']))),1024)    // If the file size is less than 1KB, delete the attachment.

 

 

v-xiaochen-msft_2-1611646559076.png

 

2\ Add the flow to the onselect property of the submit button in the canvas app.

Add set the onselect property of the submit button to:

SubmitForm(EditForm1);TEST19.Run(EditForm1.LastSubmit.ID,EditForm1.LastSubmit.ID)

// EditForm1 is the name of my edit form control.  TEST19 is the name of my flow.

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

Cooper01
Responsive Resident
Responsive Resident

Appreciate the response but I'm looking for a way to detect the side before the file makes it to SharePoint from the control or Power App. This will really slow down the process as uploading the file is only one part of a multi step form.

v-xiaochen-msft
Community Support
Community Support

Hi @Cooper01 ,

 

At present, this may be difficult to achieve.

Logically, a local file needs to be uploaded to get its file size.

This step is to upload the file to the attachment column of the cloud list.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

Cooper01
Responsive Resident
Responsive Resident

Just looking for clarification you say it's difficult but is it at all possible without completing the upload action?

v-xiaochen-msft
Community Support
Community Support

Hi @Cooper01 ,

 

It seems that it can only upload the file to the attachment column first, then automatically obtain the size of the file, and finally decide whether to keep the file or delete the file based on the size.

Because in your app, users upload local files.

 

If you have many files in the sharepoint library(in cloud), you could decide whether to move them to the attachment column according to their size. This can avoid completing the upload action.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (36,680)