Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge commit '434716e1d' into dinsic
Browse files Browse the repository at this point in the history
* commit '434716e1d':
  Fetch from the r0 media path instead of the unspecced v1. (#7714)
  • Loading branch information
anoadragon453 committed Aug 3, 2020
2 parents 09ddede + 434716e commit 3261eb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/7714.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Synapse will now fetch media from the proper specified URL (using the r0 prefix instead of the unspecified v1).
8 changes: 4 additions & 4 deletions synapse/rest/media/v1/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ async def _download_remote_file(self, server_name, media_id, file_id):

with self.media_storage.store_into_file(file_info) as (f, fname, finish):
request_path = "/".join(
("/_matrix/media/v1/download", server_name, media_id)
("/_matrix/media/r0/download", server_name, media_id)
)
try:
length, headers = await self.client.get_file(
Expand Down Expand Up @@ -703,7 +703,7 @@ class MediaRepositoryResource(Resource):
Uploads are POSTed to a resource which returns a token which is used to GET
the download::
=> POST /_matrix/media/v1/upload HTTP/1.1
=> POST /_matrix/media/r0/upload HTTP/1.1
Content-Type: <media-type>
Content-Length: <content-length>
Expand All @@ -714,7 +714,7 @@ class MediaRepositoryResource(Resource):
{ "content_uri": "mxc://<server-name>/<media-id>" }
=> GET /_matrix/media/v1/download/<server-name>/<media-id> HTTP/1.1
=> GET /_matrix/media/r0/download/<server-name>/<media-id> HTTP/1.1
<= HTTP/1.1 200 OK
Content-Type: <media-type>
Expand All @@ -725,7 +725,7 @@ class MediaRepositoryResource(Resource):
Clients can get thumbnails by supplying a desired width and height and
thumbnailing method::
=> GET /_matrix/media/v1/thumbnail/<server_name>
=> GET /_matrix/media/r0/thumbnail/<server_name>
/<media-id>?width=<w>&height=<h>&method=<m> HTTP/1.1
<= HTTP/1.1 200 OK
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/media/v1/test_media_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _req(self, content_disposition):
self.assertEqual(len(self.fetches), 1)
self.assertEqual(self.fetches[0][1], "example.com")
self.assertEqual(
self.fetches[0][2], "/_matrix/media/v1/download/" + self.media_id
self.fetches[0][2], "/_matrix/media/r0/download/" + self.media_id
)
self.assertEqual(self.fetches[0][3], {"allow_remote": "false"})

Expand Down

0 comments on commit 3261eb7

Please sign in to comment.