Advertisement
boky8

File explorer shema

Sep 29th, 2019
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type Guid = string; // Guid is basically stirng
  2.  
  3. // Explorer item - may be folder or file (folder returns 1 level of its children)
  4. interface ExplorerItem {
  5.     id: Guid;
  6.     createdById: number;            // id of user who created item
  7.     createdTimestamp: Date;         // timestamp when item was created
  8.     modifiedById: number;           // id of user who created/modified item
  9.     modifiedTimestamp: Date;        // timestamp when item was modified
  10.     latestVersion: number;          // latest version of this folder item
  11.     parent: Guid;                   // guid of parent folder item (null if root)
  12.     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)
  13.     name: string;                   // display name for this item (file will be downloaded by that given name)
  14.     type: string;                   // mime type ("inode/directory" for folders)
  15.     size: number;                   // size in bytes (null for folders)
  16.     favorite: boolean;              // is folder item marked as favorite
  17.     inTrash: boolean;               // is folder in trash
  18.     children?: ExplorerItem[];      // if folder, show child items
  19. }
  20.  
  21. // Modified ExplorerItem type, but for folders
  22. interface ExplorerItemDirectory extends ExplorerItem {
  23.     latestVersion: 1;
  24.     type: 'inode/directory';
  25.     size: null;
  26.     children: ExplorerItem[];
  27. }
  28.  
  29. // Modified ExplorerItem type, but for files
  30. interface ExplorerItemFile extends ExplorerItem {
  31.     latestVersion: number;
  32.     children: null;
  33. }
  34.  
  35. // Model for folder creation
  36. interface CreateFolder {
  37.     parent: Guid;
  38.     name: string;
  39. }
  40.  
  41. /*
  42.  
  43. GET     /explorer                           - get root folder item
  44. GET     /explorer/:id                       - get folder item by id
  45. GET     /explorer/favorites                 - get favorite folder items
  46. POST    /explorer/:id/favorite              - mark folder item as favorite
  47. DELETE  /explorer/:id/favorite              - remove favorite mark for folder item
  48. POST    /explorer                           - create folder in root (CreateFolder model)
  49. POST    /explorer/:id                       - create folder, "id" param is parent id (CreateFolder model)
  50. POST    /explorer/upload                    - upload file to root (multipart form data)
  51. POST    /explorer/:id/upload                - upload file, "id" param is parent id (multipart form data)
  52. POST    /explorer/:id/upload/new_version    - upload new version of file, "id"
  53. GET     /explorer/:id/download              - download file with given id
  54. ?POST   /explorer/:id/generate_token?ref=X  - temporary generate public token for file ("id" param)
  55. ?GET    /explorer/download?token=X          - download file with public token
  56. DELETE  /explorer/:id                       - moves file ("id" param) or folder to trash
  57. DELETE  /explorer/trash                     - deletes all files and folders from trash
  58. DELETE  /explorer/trash/:id                 - deletes file ("id" param) from trash forever
  59. PUT     /explorer/trash/:id/restore         - restore file or folder ("id" param) from trash
  60. PUT     /explorer/:id/move                  - move folder item ("id" param) to root
  61. PUT     /explorer/:id/move/:parent          - move folder item to new parent ("parent" param)
  62. POST    /explorer/:id/copy                  - make copy of file ("id" param) to root
  63. POST    /explorer/:id/copy/:parent          - make copy of file to the parent ("parent" param)
  64. PUT     /explorer/:id/rename?name=X         - rename folder item
  65. GET     /explorer/search?q=X                - search folder items
  66.  
  67. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement