0sumcode / 0up

0up is a zero-knowledge, open-source, encrypted file sharing service
https://0up.io
MIT License
114 stars 8 forks source link

why not dropping the db? #2

Open sscarduzio opened 7 months ago

sscarduzio commented 7 months ago

Why did you need the database at all? Available files could just be pulled by S3. Every file in S3 has metadata you can fill with extra info if needed. If you drop Postgres this can be a frontend only tool, quite neat.

danhstevens commented 7 months ago

That is a really nice idea. There are a couple of setbacks but it's certainly worth exploring.

  1. An upload can contain many files - so would need to nest all uploaded files in a path. (easy enough)
  2. S3 charges per GET request and more requests would be required. Potential for extra costs - especially if abused by an attacker
  3. Perhaps a little bit slower than hitting a local database

Nonetheless, I do like that approach. I'll explore it some more and report back 😊

Thanks!

domlen2003 commented 7 months ago

Idea

Another approach would probably be "DB" and "Server" Adapters so you could swap around the backend and DB as you like.

Motivation

E.g. on Cloudflare the D1 (sqlite) and R2 (S3) are free up to a huuuge amount of requests and memory. Also you can host on Pages and use 100k Worker calls a day for free.

If I could deploy to Cloudflare by just linking this repo and creating an D1 and R2 this would be a no brainer.

Achievability

I think this could actually be done fairly easy since svelte supports many hosting solutions out of the box. The DB adapters should be just some config and interfaces + class impls really.

danhstevens commented 7 months ago

@domlen2003 I agree making the db more agnostic so it can work with D1, etc is worth exploring. I looked into removing the db altogether and it's not feasible mainly because of the "max downloads" variable that needs to be incremented.