feat: init

This commit is contained in:
montaghanmy
2023-03-23 11:03:16 +01:00
commit 10fe6f78d1
11518 changed files with 509786 additions and 0 deletions
@@ -0,0 +1,34 @@
---
description: File on Twake
---
# 📄 Files
## description
**Files** is everything related to file upload in Twake after the migration to Node.js. Note that the Twake Drive isn't part of this migration because it will be replaced by Linshare.
Twake Files upload support chunk upload and file encryption.
## Wording
**File:** document to upload, no constraint on the type of document \(image, text, pdf ..\)
**Chunk:** Large file are split in multiple chunk for the upload process
## Encryption
Files and Storage services in Twake feature encryption at rest in **aes-256-cbc**.
Each file is encrypted with two layers:
- A file encryption key and iv stored in database and different for each file.
- A global encryption key and iv used in addition to the previous one and equal for each file.
## Models and APIs
[database-models](database-models.md)
## Miscellaneous
[resumablejs](resumablejs.md)
@@ -0,0 +1,40 @@
---
description: File database models
---
# Database models
* **files** The main file object in database
```javascript
javascript
{
//Primary key: [["company_id"], "id"]
"company_id": "uuid-v4",
"id": "uuid-v4",
"user_id": "string",
"application_id": "string",
"updated_at": "number",
"created_at":"number
"upload_data": (json){
"size": number, //Total file size
"chunks": number, //Number of chunks
}
"metadata": (json){
"name": "string", //File name
"mime": "type/subtype",
}
"thumbnails": (json) { //Url to thumbnail (or set it to undefined if no relevant)
"index": "string",
"id": "uuid-v4",
"type": "string",
"size": "number,
"width": number, //Thumbnail width (for images only)
"height": number, //Thumbnail height (for images only)
}
}
```
@@ -0,0 +1,25 @@
---
description: How we use resumable on Twake
---
# Resumable.js
**Link to the official documentation:** [http://resumablejs.com](http://resumablejs.com/)
## What is Resumable.js
::: info
Using Resumable is not mandatory to upload a file to Twake. You can do it manually, see REST APIs page.
:::
Its a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API.
The library is designed to introduce fault-tolerance into the upload of large files through HTTP. This is done by splitting each files into small chunks; whenever the upload of a chunk fails, uploading is retried until the procedure completes. This allows uploads to automatically resume uploading after a network connection is lost either locally or to the server. Additionally, it allows for users to pause, resume and even recover uploads without losing state.
Resumable.js does not have any external dependencies other the `HTML5 File API`. This is relied on for the ability to chunk files into smaller pieces. Currently, this means that support is limited to Firefox 4+ and Chrome 11+.
## What Resumable.js does
In Frontend side resumable split the file in multiple small chunks. For the upload process resumable ask the server with an HTTP GET request to know if the chunk requested is saved on the server side. If yes, resumable ask for the next chunk. If not, resumable send an HTTP POST request with the chunk to the server.
With POST request from resumable, there is multiple information fields contains for exemple the number of chunk, the chunk size, the total size of the file, an unique identifier for the file, and the name of the file.