Skip to content

Commit b89504d

Browse files
committed
The last chunk can be accepted asynchronously
The server is allowed to respond with a 202 for the last chunk, to indicate it's processing that last chunk asynchronously. This fleshes out the process for checking for completed process of the file in that case, and improves the file status key definitions.
1 parent a5aacbb commit b89504d

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

peps/pep-0694.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ the following keys:
298298
wishes to communicate to the end user. These notices are specific to the overall session, not
299299
to any particular file in the session.
300300

301+
301302
.. _session-links:
302303

303304
Session Links
@@ -330,8 +331,15 @@ The ``files`` key contains a mapping from the names of the files uploaded in thi
330331
sub-mapping with the following keys:
331332

332333
``status``
333-
A string with the same values and semantics as the :ref:`session status key <session-status>`,
334-
except that it indicates the status of the specific referenced file.
334+
A string with valid values ``partial``, ``pending``, ``complete``, and ``error``. If a file
335+
upload has not seen an ``Upload-Complete: ?1`` header, then ``partial`` will be returned. If
336+
``Upload-Complete: ?1`` resulted in a ``202 Accepted``, then ``pending`` will be returned until
337+
asynchronous processing of the last chunk and the full file has been completed. If a ``201
338+
Created`` was returned, or the last chunk processing is finished, ``complete`` will be returned.
339+
If there was an error during upload, then clients should not assume the file is in any usable
340+
state, ``error`` will be returned and it's best to :ref:`cancel or delete <cancel-an-upload>`
341+
the file and start over. This action would remove the file name from the ``files`` key of the
342+
:ref:`session status response body <session-response>`.
335343

336344
``link``
337345
The *absolute* URL that the client should use to reference this specific file. This URL is used
@@ -523,10 +531,13 @@ For the second chunk representing bytes 1000 through 1999, include the following
523531
These requests would continue sequentially until the last chunk is ready to be uploaded.
524532

525533
For each successful chunk, the server **MUST** respond with a ``202 Accepted`` header, except for
526-
the final chunk, which **MUST** be a ``201 Created``, and as with non-chunked uploads, the body of
527-
these responses has no content.
534+
the final chunk, which **MUST** be either:
528535

529-
.. _complete-the-upload:
536+
* ``201 Created`` if the server accepts and processes the last chunk synchronously, completing the
537+
file upload.
538+
* ``202 Accepted`` if the server accepts the last chunk, but must process it asynchronously. In
539+
this case, the client should query the :ref:`session status <session-response>` periodically until
540+
the uploaded :ref:`file status <session-file>` transitions to ``complete``.
530541

531542
The final chunk of data **MUST** include the ``Upload-Complete: ?1`` header, since at that point the
532543
entire file has been uploaded.

0 commit comments

Comments
 (0)