Upload Filesize Limit
I searched but couldn't find how to limit the file size for uploads in XANO.
Is this possible somehow?
If not, I think this would be a really good feature to save bandwidth.
Best Answers
-
Hey @oburrell the metadata of when you create the file gives you the size of the file in bytes. You can set a precondition to enforce that the file the user is uploading is less than a byte size that you specify.
Here is a similar video where you can enforce a user's total uploads are under a certain size but you can apply similar logic with the precondition on an individual upload basis.
-
This is a great method! Getting the file resource data allows you to check the size before creating the file at all. Order of operations matters which is why you didn't find success with the Precondition in position 1. Nice solution :)
Answers
-
I am trying to limit the file size for each uploaded file to say 3MB and created the endpoint like this:
This works but I am not quite sure if there is a better way. First I tried to have the Precondition first in the function stack and no "Get File Resource Data" but at that point the size is not known. It seems that the file gets downloaded twice this way (first at the "Get File Resource Data" and again with the "Create Attachment From File").
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback