diff --git a/docs/files.rst b/docs/files.rst index 3254636..93f27ad 100644 --- a/docs/files.rst +++ b/docs/files.rst @@ -1,6 +1,25 @@ Files API ========= +Overview +-------- +The file upload process essentially works as follows: + +#. ``POST /files`` with the metadata to create a share. + This will return an URL with the share you just created. + (See :ref:`files_list_api`.) +#. ``POST /files//content`` (the UUID is in the URL from the previous step) to upload the actual data of the share. (See :ref:`files_content_api`.) +#. ``GET /files//content`` to read the share. + +Share modification is done with ``PUT /files//content``. + +Shares can be locked, which means they can't be modified or deleted. +See :ref:`files_lock_api` for more information. + +.. note:: + + All data uploads are chunked: see :ref:`files_chunked_upload`. + .. _files_schema: File Schema @@ -35,7 +54,7 @@ In JSON, a file share has the following properties:: * - ``locked`` - Boolean - Read-only - - Shows if share is locked. + - Shows if share is locked (see :ref:`files_lock_api`.) * - ``owner_name`` - string - @@ -45,6 +64,8 @@ In JSON, a file share has the following properties:: - Read-only - UUID that uniquely identifies this share. +.. _files_metadata_api: + Metadata API ------------ @@ -112,6 +133,38 @@ For example: The permissions from the schema that are missing here are read-only. +.. _files_list_api: + +List API +-------- + +The File List API allows listing shares and creating new ones:: + + GET /files + POST /files + +GET +^^^ + +``GET /files`` is a :ref:`paginated endpoint` that returns a list of shares. + +To access this endpoint, a user needs the :ref:`list shares` permission. + +POST +^^^^ + +``POST /files`` creates a new share. +The request body must conform to the :ref:`File schema`. + +To access this endpoint, a user needs the :ref:`create shares` permission. + +.. note:: + + The share created here is empty, and only contains metadata. + See :ref:`files_content_api` for information on uploading content. + +.. _files_content_api: + Content API ----------- @@ -123,6 +176,40 @@ Sachet implements the following endpoints for this API:: PUT /files//content GET /files//content +POST +^^^^ + +``POST /files//content`` initializes the content of an empty share. +This endpoint requires the :ref:`create shares` permission. + +.. note:: + + You must first create a share before initializing it: see :ref:`files_list_api` for information about creation. + +Uploads must be chunked (see :ref:`files_chunked_upload`). + +To modify the contents of an existing share, use ``PUT`` instead. + +PUT +^^^^ + +``PUT /files//content`` modifies the content of an existing share. +This endpoint requires the :ref:`modify shares` permission. + +.. note:: + + You must initialize a share's content using ``POST`` before modifying it. + +Uploads must be chunked (see :ref:`files_chunked_upload`). + +GET +^^^^ + +``GET /files//content`` reads the contents of a share. +This endpoint requires the :ref:`read shares` permission. + +This endpoint supports `HTTP Range `_ headers. + .. _files_chunked_upload : Chunked upload protocol @@ -141,7 +228,7 @@ the server will instead respond with ``201 Created``. Every chunk has the following schema: -.. _files_chunk_schema : +.. _files_chunk_schema: .. code-block:: @@ -173,3 +260,24 @@ Every chunk has the following schema: * - ``upload`` - Binary data (file) - Data contained in this chunk. + +.. _files_lock_api: + +Lock API +-------- + +Files can be locked and unlocked. +When locked, a share can not be modified or deleted. + +.. note:: + + When attempting illegal actions on a locked share, the server will respond ``423 Locked``. + +The following API is used:: + + POST /files//lock + POST /files//unlock + +A user needs the :ref:`lock permission` to access this API. + +To query whether a file is locked or not, see :ref:`files_metadata_api`. diff --git a/docs/permissions.rst b/docs/permissions.rst index 73648ee..dcece3f 100644 --- a/docs/permissions.rst +++ b/docs/permissions.rst @@ -49,7 +49,7 @@ The following is a table of permissions Sachet offers, and what they do: - Allows users to delete any share. * - Lock shares - ``LOCK`` - - Allows users to lock and unlock shares. + - Allows users to lock and unlock shares (see :ref:`files_lock_api`). * - List shares - ``LIST`` - Allows users to list all shares from all users. diff --git a/docs/user.rst b/docs/user.rst index 6f4a98a..7e058d5 100644 --- a/docs/user.rst +++ b/docs/user.rst @@ -133,5 +133,5 @@ GET POST ^^^^ -``POST /users/`` creates a new user. +``POST /users`` creates a new user. The request body must conform to the :ref:`User schema`.