chainstep / dibichain-demo

A prototype for anonymous data sharing
GNU General Public License v3.0
3 stars 0 forks source link

files to database #5

Closed atz3n closed 2 years ago

atz3n commented 2 years ago

we need to provide the route /my-documents with which it should be possible to send files. We then should store them in our database somehow.

A package that can handle multipart/form-data is multer. Maybe it's a good idea to use it.

The following specification is to be reviewed and implemented.

DOCUMENTS

header header
endpoint: /my-documents
method: POST
content-type: multipart/form-data; boundary=<boundary-string>

Parts

name type mandatory description
uid string false The requested uid of that document in the database, in UUID-format (8-4-4-4-12). Causes an error if already existing in DB. If omitted, a new version 4 UUID will be generated. The used one will be returned in the response.
filename string false The filename to be used for download. If omitted, the user has to pick a filename when downloading.
title string true The title of the document instance. Different titles can be used for the same file, f.i. for generic manuals
version string false The version of the document, to be used for information, sorting, identification on display.
type string true One of enum: other, LCA, dismantling
format string true One of enum: other, ILCD, JSON, BSON, PDF, JPEG, PNG or a MIME-type
hash string false (true if not files) If given, it must match the SHA-1 hash of either the sent binary filedata (if contained) or of an already existing file, otherwise an error is returned. The generated hash will be returned in the response.
uploaded string false The date and time the document was uploaded by the end-user. If omitted, the datetime of the request to that business-backend endpoint will be used. Format: UTC format or seconds since epoc, readable by javascript Date() constructor.
file string false The actual filedata of the document. If omitted, then a hash of an already existing file must be

Example

{
    uid: "c12bf992-f13a-4aad-b0e4-c0d84c257f63",
    title: "Bionic Partition Manual",
    version: "1.0",
    type: "other",
    format: "PDF",
    hash: "379f4c50b35df45827b376a60b26f910be7d231b",
    uploaded: "Mon, 26 May 2014 07:55:34 GMT"
}

Response

header header
content-type: application/json
{
    uid: string,
    title: string,
    filename: string,
    version: string,
    type: string,
    format: string,
    hash: string,
    size: number,
    uploaded: datetime
}
atz3n commented 2 years ago

solved with new aligned endpoint scheme