1
-
2
1
PEP: 694
3
2
Title: Upload 2.0 API for Python Package Indexes
4
3
Author: Barry Warsaw <
[email protected] >, Donald Stufft <
[email protected] >, Ee Durbin <
[email protected] >
@@ -702,11 +701,11 @@ the file to be uploaded. These checks may include, but are not limited to:
702
701
- checking if the contents of the ``metadata ``, if provided, are valid.
703
702
704
703
If the server determines that upload should proceed, it will return a ``202 Accepted `` response, with the
705
- response body below. The :ref: `status <publishing-session-status >` of the session will also include the filename in the
706
- ``files `` mapping. If the server cannot proceed with an upload because the `` mechanism `` supplied by the
707
- client is not supported it **MUST ** return a ``422 Unprocessable Content ``. The server ** MAY ** allow parallel
708
- uploads of files, but is not required to. If the server determines the upload cannot proceed, it ** MUST **
709
- return a ``409 Conflict ``.
704
+ response body below. The :ref: `status <publishing-session-status >` of the publishing session will also
705
+ include the filename in the ``files `` mapping. If the server cannot proceed with an upload because the
706
+ `` mechanism `` supplied by the client is not supported it **MUST ** return a ``422 Unprocessable Content ``. The
707
+ server ** MAY ** allow parallel uploads of files, but is not required to. If the server determines the upload
708
+ cannot proceed, it ** MUST ** return a ``409 Conflict ``.
710
709
711
710
.. _file-upload-session-response :
712
711
@@ -733,8 +732,8 @@ The successful response includes the following:
733
732
}
734
733
}
735
734
736
- A ``Retry-After `` response header **MUST ** be present
737
- to indicate to clients when they should next poll for an updated status.
735
+ A ``Retry-After `` response header **MUST ** be present to indicate to clients when they should next poll for an
736
+ updated status.
738
737
739
738
Besides the ``meta `` key, which has the same format as the request JSON, the success response has
740
739
the following keys:
@@ -765,14 +764,14 @@ the following keys:
765
764
File Upload Session Links
766
765
+++++++++++++++++++++++++
767
766
768
- For the ``links `` key in the success JSON , the following sub-keys are valid:
767
+ For the ``links `` key in the response payload , the following sub-keys are valid:
769
768
770
769
``file-upload-session ``
771
- The endpoint where actions for this file-upload-session can be performed.
772
- including :ref: ` canceling and discarding the file upload session <file-upload-session-cancellation >`,
773
- :ref: `querying the current file upload session status < publishing-session-status >`,
774
- and :ref: `requesting an extension of the file upload session lifetime < publishing-session-extension >`
775
- (*if * the server supports it).
770
+ The endpoint where actions for this file-upload-session can be performed. including :ref: ` completing a
771
+ file upload session <file-upload-session-completion >`, :ref: ` canceling and discarding the file upload
772
+ session <file-upload-session-cancellation>`, :ref: `querying the current file upload session status
773
+ <file-upload-session-status>`, and :ref: `requesting an extension of the file upload session lifetime
774
+ <file-upload-session-extension>` (*if * the server supports it).
776
775
777
776
.. _file-upload-session-completion :
778
777
@@ -794,42 +793,40 @@ The requests looks like:
794
793
"action" : " complete" ,
795
794
}
796
795
797
- If the server is able to immediately complete the file upload session, it may do so and return a
798
- ``201 Created `` response and set the status of the file upload session to ``complete ``.
799
- If it is unable to immediately complete the file upload session
800
- (for instance, if it needs to do validation that may take longer than reasonable in a single HTTP
801
- request), then it may return a ``202 Accepted `` response
802
- and set the status of the file upload session to ``processing ``.
796
+ If the server is able to immediately complete the file upload session, it may do so and return a ``201
797
+ Created `` response and set the status of the file upload session to ``complete ``. If it is unable to
798
+ immediately complete the file upload session (for instance, if it needs to do validation that may take longer
799
+ than reasonable in a single HTTP request), then it may return a ``202 Accepted `` response and set the status
800
+ of the file upload session to ``processing ``.
803
801
804
- In either case, the server should include a ``Location `` header pointing back to the File Upload
805
- Session status URL.
802
+ In either case, the server should include a ``Location `` header pointing back to the :ref: ` file upload session
803
+ status <file-upload-session- status>` URL.
806
804
807
- Servers **MUST ** allow clients to poll the file upload session status URL
808
- to watch for the status to change.
809
- If the server responds with a ``202 Accepted ``,
810
- clients may poll the file upload session status URL to watch for the status to change.
811
- Clients **SHOULD ** respect the ``Retry-After `` header value
812
- of the file upload session status response.
805
+ Servers **MUST ** allow clients to poll the file upload session status URL to watch for the status to change.
806
+ If the server responds with a ``202 Accepted ``, clients may poll the file upload session status URL to watch
807
+ for the status to change. Clients **SHOULD ** respect the ``Retry-After `` header value of the file upload
808
+ session status response.
813
809
814
- If an error occurs, the appropriate ``4xx `` code should be returned, as described in the
815
- :ref: `session-errors ` section.
810
+ **FIXME **: Errors
811
+
812
+ If an error occurs, the appropriate ``4xx `` code should be returned, as described in the :ref: `session-errors `
813
+ section.
816
814
817
815
818
816
.. _file-upload-session-cancellation :
819
817
820
818
Cancellation and Deletion
821
819
~~~~~~~~~~~~~~~~~~~~~~~~~
822
820
823
- A client can cancel an in-progress file upload session, or delete a file that has been
824
- completely uploaded. In both cases, the client performs this by issuing a ``DELETE `` request to
825
- the file upload session URL of the file they want to delete.
821
+ A client can cancel an in-progress file upload session, or delete a file that has been completely uploaded.
822
+ In both cases, the client performs this by issuing a ``DELETE `` request to the ``links.file-upload-session ``
823
+ URL from the :ref: `file upload session creation response <file-upload-session-response >` of the file they want
824
+ to delete.
826
825
827
826
A successful deletion request **MUST ** respond with a ``204 No Content ``.
828
827
829
- Once canceled or deleted, a client **MUST NOT ** assume that
830
- the previous file upload session resource
831
- or associated file upload mechanisms
832
- can be reused.
828
+ Once canceled or deleted, a client **MUST NOT ** assume that the previous file upload session resource or
829
+ associated file upload mechanisms can be reused.
833
830
834
831
835
832
Replacing a Partially or Fully Uploaded File
@@ -838,13 +835,52 @@ Replacing a Partially or Fully Uploaded File
838
835
To replace a session file, the file upload **MUST ** have been previously completed, canceled, or
839
836
deleted. It is not possible to replace a file if the upload for that file is in-progress.
840
837
841
- To replace a session file, clients should
842
- :ref: `cancel and delete the in-progress upload <file-upload-session-cancellation >` by
843
- issuing a ``DELETE `` to the upload resource URL for the file they want to replace.
844
- After this, the new file upload can be initiated by beginning
845
- the entire :ref: `file upload <file-upload-session >` sequence over again.
846
- This means providing the metadata request again to retrieve a new upload resource URL.
847
- Clients **MUST NOT ** assume that the previous upload resource URL can be reused after deletion.
838
+ To replace a session file, clients should :ref: `cancel and delete the in-progress upload
839
+ <file-upload-session-cancellation>` first. After this, the new file upload can be initiated by beginning the
840
+ entire :ref: `file upload <file-upload-session >` sequence over again. This means providing the metadata
841
+ request again to retrieve a new upload resource URL. Clients **MUST NOT ** assume that the previous upload
842
+ resource URL can be reused after deletion.
843
+
844
+ .. _file-upload-session-status :
845
+
846
+ File Upload Session Status
847
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
848
+
849
+ The client can query status of the file upload session by issuing a ``GET `` request to the
850
+ ``links.file-upload-session `` URL from the :ref: `file upload session creation response
851
+ <file-upload-session-response>`. The server responds to this request with the same payload as the file upload
852
+ session creation response, except with any changes ``status `` and ``expires-at `` reflected.
853
+
854
+ .. _file-upload-session-extension :
855
+
856
+ File Upload Session Extension
857
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
858
+
859
+ Servers **MAY ** allow clients to extend file upload sessions, but the overall lifetime and number of
860
+ extensions allowed is left to the server. To extend a file upload session, a client issues a ``POST `` request
861
+ to the ``links.file-upload-session `` URL from the :ref: `file upload session creation response
862
+ <file-upload-session-response>`.
863
+
864
+ The request looks like:
865
+
866
+ .. code-block :: json
867
+
868
+ {
869
+ "meta" : {
870
+ "api-version" : " 2.0"
871
+ },
872
+ "action" : " extend" ,
873
+ "extend-for" : 3600
874
+ }
875
+
876
+ The number of seconds specified is just a suggestion to the server for the number of additional seconds to
877
+ extend the current file upload session. For example, if the client wants to extend session for another hour,
878
+ ``extend-for `` would be ``3600 ``. Upon successful extension, the server will respond with the same :ref: `file
879
+ upload session creation response body <file-upload-session-response>` that they got when they initially
880
+ created the publishing session, except with any changes to ``status `` or ``expires-at `` reflected.
881
+
882
+ If the server refuses to extend the session for the requested number of seconds, it **MUST ** still return a
883
+ success response, and the ``expires-at `` key will simply reflect the current expiration time of the session.
848
884
849
885
850
886
.. _staged-preview :
0 commit comments