From 96febd0337ae2c4e69e124d2b4ac2688d6738743 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Tue, 16 May 2023 19:25:31 +0100 Subject: [PATCH 1/4] Add `allow_redirect` query parameter to relevant media endpoints --- data/api/client-server/content-repo.yaml | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/data/api/client-server/content-repo.yaml b/data/api/client-server/content-repo.yaml index 328ae1c40..7b35accd1 100644 --- a/data/api/client-server/content-repo.yaml +++ b/data/api/client-server/content-repo.yaml @@ -308,6 +308,16 @@ paths: content repository can and should impose a maximum value for this parameter. The content repository may also choose to respond before the timeout. + - in: query + type: boolean + name: allow_redirect + x-example: false + required: false + default: false + description: | + Indicates to the server that it may return a 307 or 308 redirect response that points + at the relevant media content. When not explicitly set to true the server must return + the media content itself. responses: 200: description: "The content that was previously uploaded." @@ -404,6 +414,16 @@ paths: content repository can and should impose a maximum value for this parameter. The content repository may also choose to respond before the timeout. + - in: query + type: boolean + name: allow_redirect + x-example: false + required: false + default: false + description: | + Indicates to the server that it may return a 307 or 308 redirect response that points + at the relevant media content. When not explicitly set to true the server must return + the media content itself. responses: 200: description: "The content that was previously uploaded." @@ -518,6 +538,16 @@ paths: content repository can and should impose a maximum value for this parameter. The content repository may also choose to respond before the timeout. + - in: query + type: boolean + name: allow_redirect + x-example: false + required: false + default: false + description: | + Indicates to the server that it may return a 307 or 308 redirect response that points + at the relevant media content. When not explicitly set to true the server must return + the media content itself. responses: 200: description: "A thumbnail of the requested content." From 8e81354f3d9c807e278d613be62f2e1c7ad679d0 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Tue, 16 May 2023 20:31:47 +0100 Subject: [PATCH 2/4] Add added in version flag to `allow_redirect` params --- data/api/client-server/content-repo.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/api/client-server/content-repo.yaml b/data/api/client-server/content-repo.yaml index 7b35accd1..7b574c2e6 100644 --- a/data/api/client-server/content-repo.yaml +++ b/data/api/client-server/content-repo.yaml @@ -311,6 +311,7 @@ paths: - in: query type: boolean name: allow_redirect + x-addedInMatrixVersion: "1.7" x-example: false required: false default: false @@ -417,6 +418,7 @@ paths: - in: query type: boolean name: allow_redirect + x-addedInMatrixVersion: "1.7" x-example: false required: false default: false @@ -541,6 +543,7 @@ paths: - in: query type: boolean name: allow_redirect + x-addedInMatrixVersion: "1.7" x-example: false required: false default: false From f74eb070c02c0e573eb06cc37c891d6116b45c72 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Tue, 16 May 2023 20:48:57 +0100 Subject: [PATCH 3/4] Add 307/308 responses to media endpoints --- data/api/client-server/content-repo.yaml | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/data/api/client-server/content-repo.yaml b/data/api/client-server/content-repo.yaml index 7b574c2e6..e12c5612f 100644 --- a/data/api/client-server/content-repo.yaml +++ b/data/api/client-server/content-repo.yaml @@ -334,6 +334,18 @@ paths: type: file # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the uploaded file." + 307: + description: "A redirect to the thumbnail of the requested content." + headers: + Location: + description: "The URL of the thumbnail content." + type: "string" + 308: + description: "A redirect to the thumbnail of the requested content." + headers: + Location: + description: "The URL of the thumbnail content." + type: "string" 429: description: This request was rate-limited. schema: @@ -442,6 +454,18 @@ paths: type: file # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the uploaded file." + 307: + description: "A redirect to the thumbnail of the requested content." + headers: + Location: + description: "The URL of the thumbnail content." + type: "string" + 308: + description: "A redirect to the thumbnail of the requested content." + headers: + Location: + description: "The URL of the thumbnail content." + type: "string" 429: description: This request was rate-limited. schema: @@ -563,6 +587,18 @@ paths: type: file # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the thumbnail." + 307: + description: "A redirect to the thumbnail of the requested content." + headers: + Location: + description: "The URL of the thumbnail content." + type: "string" + 308: + description: "A redirect to the thumbnail of the requested content." + headers: + Location: + description: "The URL of the thumbnail content." + type: "string" 400: description: |- The request does not make sense to the server, or the server cannot thumbnail From 6e5e91d374d356575620b4ed56631c96eba9ec11 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Tue, 16 May 2023 20:54:48 +0100 Subject: [PATCH 4/4] Add changelogs --- changelogs/client_server/newsfragments/1529.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/client_server/newsfragments/1529.feature diff --git a/changelogs/client_server/newsfragments/1529.feature b/changelogs/client_server/newsfragments/1529.feature new file mode 100644 index 000000000..48f1d90ba --- /dev/null +++ b/changelogs/client_server/newsfragments/1529.feature @@ -0,0 +1 @@ +Addition of redirect downloads, as per [MSC3860](https://github.com/matrix-org/matrix-spec-proposals/pull/3860).