cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Resolver IV
Resolver IV

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
Microsoft
Microsoft

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
Microsoft
Microsoft

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
Resolver IV
Resolver IV

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
Microsoft
Microsoft

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
Resolver IV
Resolver IV

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

v-xiaochen-msft
Microsoft
Microsoft

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
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (62,270)