Artifact Upload
===============

File uploading is necessary for report submission and slides sharing.
These files are called "artifact".
Only students of a project can upload these artifacts.

The process involves three storages:

- ``projects`` database table
- ``files`` database table
- IPFS

Uploading artifacts starts with user submitting a file via browser.
A file controller receives it and add to the file system,
IPFS.  After adding the file, a CID is generated by IPFS and returned
to the controller.  Consequently, metadata about the file, including
the CID, is added as a row in the table ``files``.
The database management system, RethinkDB, generates a primary key
for this row, which is then added to project artifact revisions.

.. uml:: uml/file-upload.puml
   :caption: General message sequence for artifact uploading.
   :name: upload

In case of uploading files for other purposes, such as including a picture in
a comment, is similar to the flow described above. However,
the primary key is not stored in the project, and the link to the stored file
is returned instead.
