Back

Custom size limit per user

  • 0
  • Web
  • Storage
igrir
1 Aug, 2023, 23:48

Hello everyone! I'm planning to have tiered upload functionality on my apps. Pretty much like discord. for an example in free tier you can upload file up to 1MB, but in "premium" tier you can upload up to 10MB. I'm planning to handling those things on client ( I'm using Javascript) by checking user's current plan and check the file size before the upload. What do you think? Is it good? or maybe is there any built in functions in appwrite to limit specific size upload on specific group? thanks!

TL;DR
The user wants to implement a custom size limit per user for file uploads. They are considering handling it on the client side by checking the user's plan and file size before uploading. Other users suggest using different upload buckets, one for premium and one for basic users, and using a function to process the file and move it to the appropriate bucket. Client side validation is discouraged.
Drake
1 Aug, 2023, 23:53

I'm planning to handling those things on client ( I'm using Javascript) by checking user's current plan and check the file size before the upload

Client side validation is not safe.

What if you different upload buckets. one premium and 1 basic. and a user will only have access to the preimum one if they're in the premium tier.

Then, you have a function that triggers when a file gets uploaded, processes the file, and moves it to a bucket where it can be fetched

The processing can be really helpful to do things like resize, remove metadata, etc

igrir
2 Aug, 2023, 00:24

Aah, I see. So selecting which bucket to be used is happening inside the client, right? The premium and non premium can be validated by enroll them to specific group, then let appwrite validate the eligibility of their file upload by setting which group can upload to that specific bucket

Drake
2 Aug, 2023, 00:28

and even if the non-premium one tries to upload to the premium bucket, it will fail (server side validation) so they can't try to bypass it

igrir
2 Aug, 2023, 00:36

Cool! It would be act as double protection

igrir
2 Aug, 2023, 00:37

you mentioned function, is it cloud function? does it mean I need 3 bucket? the upload one and 2 tiered bucket?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more