Tracking a User's Storage Useage

Has anyone found a way to track how much storage a user is using. I am looking to possibly set up limits per user to prevent one user from using too much of the app’s storage.

1 Like

You can save how much storage users are using to your database, either by simply creating a number field on the user, or a more advanced whole new dataType which also saves the individual file sizes.

Some file uploading plugins expose the filesizes of their inputs. If file uploading and management is a big component of you app i would recommend a more advanced file uploader than the bubble native one. For example Better Uploader Plugin | Bubble has worked great for me.

After setting up the database and workflows for uploading/saving file size onto the database, you simply need to check that the user has uploaded less than what their plan allows, and disable the input if they surpassed it. Better Uploader allows you to upload the files to the browser before saving them to the database. This lets you check whether the next image will exceed the plan’s usage if uploaded, and also do stuff like image compression before saving it to the database.

1 Like

Hi Nico, thank you for the details. So I would need to use specific upload plugins (not the native bubble ones) to get this type of information?

And then to add that to a data field on the user that is a number in MBs I would guess?

Have you set something like this up before?

You can try this plugin: Head Request / Get File Info Plugin | Bubble to get file info after the upload and like @nico.dicagno said, store the info in number field.

However, you should probably have a “files” db where each file will be store with their own information and you can use :sum for each files related to the user.

1 Like

You wouldn’t need to, but it is a way forward. As @jici mentioned you can also request image head. However i have personally found it to be too slow at times, and you also have to set up a loop if multiple images are uploaded.

I think better uploader is a much better uploader :grin: than the native uploader.
The plugin exposes image previews with the ‘raw data’ parameter much sooner than the native uploader could ever upload the images. And you also have more control over when you want to upload the picture to your database; you don’t need to do it immediately (or at all). And it quickly exposes the file size so it would be great for your use-case.

Having a ‘file’ datatype with file size field + any other field you’d require would absolutely be the best way forward.

Just make sure to double check the units. Better uploader returns MB, but if you request the header of the image it would be in bytes.