Archived from the Transloadit support forum. Originally posted on November 17, 2013; details may be outdated, see our docs for current behavior. Original thread
Hi all,
Sometimes we want to use transloadit on a platform that will be used for different customers.
The problem we face is how to make sure customers only use their upload space and don’t overscript others.
For example, as a transloadit customer, imagine i have a 100GB plan.
Now, if i have 20 customers that will use all my templates how can i specify that each costumer can only use 5GB each month. I need to make sure every customer has its 5GB reserved and no one use more than 5GB.
I came with a simple feature for it. Let me share.
What do you think to add quota setting in the export robots?
eg:
@@@
"rackspace": {
"robot": "/cloudfiles/store",
"container": "mycontainer",
"account_type": "uk",
"user": "myuser",
"key": "REDACTED",
"use": [
"original"
],
"quota_user": "customer1",
"quota_limit": "5000",
"quota_webhook_80": "http://domain.com/sendcustomeremailaboutlimit/customer1"
}
@@@
This way, when customer1 uploads a file:
- original will be stored if customer1 quota is below 5000MB and costumer1 quota will be increased by file size uploaded;
- otherwise, customer1 will get a error message when uploading about quota exceed and file is not stored;
additionally, if current quota is between 80% and 100% transloadit will call a curl to quota_webhook_80 so that our platform can notify customer1 and make all adjustments.
On transloadit control-panel monthly-usage we would get robot sizes.. see attach example
This would be really amazing and very very useful.
I don’t think Transloadit should do this. This is really app-level logic and you can implement this easily as we return how many bytes an assembly costed altogether in the result JSON. You can keep track of this and forbid users to upload more if they reach a quota.
If you want to do this by upload file size, you can also do that as we return the file sizes in the “uploads” array in the result JSON.
Hi Tim,
The problem i see with your suggestion is that if anyone get a previous js (that contains my template_id) can still upload files using transloadit.
You identify the user via a UUID (for example), then check your db records for how much this user has uploaded. If he exceeded the quote, he gets an error message, if not, then the upload form is displayed.
You fill your database entries by accumulating the assembly cost in bytes that Transloadit gave back to you in the notification response.
Hi Tim,
Your solution works.. i can create a internal counter and if counters exceeds i just don’t display form.
The “special” issue i tried to explain is that, if user opens several windows (before exceed limit) he can always upload 1 file per window. If user quota limit is 5GB and he opens 10 windows when has used 4GB “quota” and upload limit is 500MB, he will be able to upload more 5GB (a total of 9GB) if he do that in 1 hour timeout, right?
What i try to say is that, when a user see a form we can create multiple browser tabs with same form and upload multiple files if done at same time (before transloadit signature expires). Because quota is check after a upload is done this is a risk.
Yeah right I understand but that will happen cery rarely and you could ban these users right away or charge them extra as it is against your terms of service.