-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Requirements:
- User can upload a file
- API should feel familiar
- The metadata of the file should be described using Atomic Data
- Existing Atomic Data Authorization + Authentication should be used
I currently use actix-files for static file hosting. Not sure how this could be replaced. It does a lot of fancy stuff, such as setting mimetype, checking modified_at, etag...
Some approaches:
Use existing filesystem for storage
- We could keep using actix-files, and serve files directly from some pre-defined endpoint(s).
- Commits might still be described in the store. However, the 'initial commit' might have a risk of not existing with this approach. Perhaps add a single commit on initial load.
- How to deal with authorization? I'd rather not have every single static item public
- How to deal with indexing and search? Would a TPF query hit all these items?
- Easy to implement
- High degree of control over folder, easy to use, easy to manage
- Might cause OS-specific filesystem quirks (things with folders and rights, max file length, whatever)
- Hard to secure
- Does not scale well
Files as Resources in the Atomic Data Store
We could add a new type of resource, which has a filename, size, bytearray / string, mimetype. This would mean that we could use existing Resource logic - including things like commits and the TPF index.
However, including the bytearray would make things very slow for uploading / using the data, as it needs to be (de)serializes as base64 to appear in JSON-AD.
Store files in the DB
Files are a new datatype, which contains just a big u8 array + a MIME type or something
- Harder to implement - especially the HTTP side of things (ByteServing, mime headers for all files). I'd rather not.
- Forces me to think about how files work in atomic data - which is probably a good thing.
- Harder for users to manage - hard to beat a filesystem.
- Possible to encrypt files
- Possible for the server to give guarantees over files - server has more control over DB than filesystem
- Might be hard to optimize / make performant (even though I use a simple K/V store as DB)
Use an S3 like external object storage system
Instead on relying on Atomic server itself to deal with storing stuff, we can use some external object storage service. Mimio is an interesting open source contender.
- Scales well for more centralized servers working with Atomic
- Doesn't fit well with the no-dependencies proposition of Atomic.
Persist using IPFS library / addon / instance
IPFS #66 could be used as an addon / crate to atomic-server that deals with the complexities of IPFS (connecting to peers, hashing, resolving identifiers to binary arrays).
Maybe ipfs-embed is a nice option for this. Contrary to rust-ipfs, this one seems to support adding (inserting) byte arrays to IPFS.