Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Guid = string; // Guid is basically stirng
- // Explorer item - may be folder or file (folder returns 1 level of its children)
- interface ExplorerItem {
- id: Guid;
- createdById: number; // id of user who created item
- createdTimestamp: Date; // timestamp when item was created
- modifiedById: number; // id of user who created/modified item
- modifiedTimestamp: Date; // timestamp when item was modified
- latestVersion: number; // latest version of this folder item
- parent: Guid; // guid of parent folder item (null if root)
- path: string; // path of item, where is located (path doesn't contain item name and never ends with "/", it may be "/" character only if path is root)
- name: string; // display name for this item (file will be downloaded by that given name)
- type: string; // mime type ("inode/directory" for folders)
- size: number; // size in bytes (null for folders)
- favorite: boolean; // is folder item marked as favorite
- inTrash: boolean; // is folder in trash
- children?: ExplorerItem[]; // if folder, show child items
- }
- // Modified ExplorerItem type, but for folders
- interface ExplorerItemDirectory extends ExplorerItem {
- latestVersion: 1;
- type: 'inode/directory';
- size: null;
- children: ExplorerItem[];
- }
- // Modified ExplorerItem type, but for files
- interface ExplorerItemFile extends ExplorerItem {
- latestVersion: number;
- children: null;
- }
- // Model for folder creation
- interface CreateFolder {
- parent: Guid;
- name: string;
- }
- /*
- GET /explorer - get root folder item
- GET /explorer/:id - get folder item by id
- GET /explorer/favorites - get favorite folder items
- POST /explorer/:id/favorite - mark folder item as favorite
- DELETE /explorer/:id/favorite - remove favorite mark for folder item
- POST /explorer - create folder in root (CreateFolder model)
- POST /explorer/:id - create folder, "id" param is parent id (CreateFolder model)
- POST /explorer/upload - upload file to root (multipart form data)
- POST /explorer/:id/upload - upload file, "id" param is parent id (multipart form data)
- POST /explorer/:id/upload/new_version - upload new version of file, "id"
- GET /explorer/:id/download - download file with given id
- ?POST /explorer/:id/generate_token?ref=X - temporary generate public token for file ("id" param)
- ?GET /explorer/download?token=X - download file with public token
- DELETE /explorer/:id - moves file ("id" param) or folder to trash
- DELETE /explorer/trash - deletes all files and folders from trash
- DELETE /explorer/trash/:id - deletes file ("id" param) from trash forever
- PUT /explorer/trash/:id/restore - restore file or folder ("id" param) from trash
- PUT /explorer/:id/move - move folder item ("id" param) to root
- PUT /explorer/:id/move/:parent - move folder item to new parent ("parent" param)
- POST /explorer/:id/copy - make copy of file ("id" param) to root
- POST /explorer/:id/copy/:parent - make copy of file to the parent ("parent" param)
- PUT /explorer/:id/rename?name=X - rename folder item
- GET /explorer/search?q=X - search folder items
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement