refactor(media): upload pieces are PUT, not PATCH
A piece at an offset is idempotent, which is what PUT means. Java's HttpURLConnection, which the Kotlin port uses, refuses PATCH outright. nginx also retries PUT on the next upstream by default but never PATCH, so the docs now only ask for non_idempotent on the start/status POST. The protocol is unreleased, so nothing else depends on the old method. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -117,7 +117,7 @@ Routes: `/v1/media/:id`, `/v1/media/:id/upload`, `/v1/live/:channelId` (WebSocke
|
||||
|
||||
A sealed file larger than 16 MiB is not one request. `shade media put` (and
|
||||
`MediaClient.putSealed`) starts an upload (`POST /v1/media/:id/upload`, signed over
|
||||
id, size and read-token hash) and sends it in pieces of 16 MiB (`PATCH`, each signed
|
||||
id, size and read-token hash) and sends it in pieces of 16 MiB (`PUT`, each signed
|
||||
over its offset and length), up to 4 at once. The relay keeps what landed on disk or
|
||||
in the bucket, so:
|
||||
|
||||
@@ -178,8 +178,9 @@ off and the rest of the server runs.
|
||||
signature, so a part damaged in transit is refused. A file sent in one `PUT` goes up
|
||||
part by part as it arrives, with at most three 16 MiB parts in memory.
|
||||
- **Behind a load balancer**, let a request that cannot reach one instance go to the
|
||||
next. Upload pieces are idempotent (a piece sent twice is a no-op), so this is safe
|
||||
even for their POST/PATCH, which nginx does not retry by default:
|
||||
next. A piece is a `PUT` (idempotent: sent twice, the second is a no-op), which
|
||||
nginx already retries on the next upstream. The `POST` that starts an upload or asks
|
||||
how far it got is just as safe to repeat, but nginx does not retry it by default:
|
||||
`location ~ ^/v1/media/[0-9a-f]+/upload$ { proxy_next_upstream error timeout non_idempotent; … }`.
|
||||
Without it the client still retries, but a balancer that keeps sending its
|
||||
retries to a dead instance makes the run stop; running it again resumes.
|
||||
|
||||
Reference in New Issue
Block a user